HOME


Mini Shell 1.0
DIR: /lib/python3/dist-packages/pygments/formatters/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/pygments/formatters/__pycache__/latex.cpython-312.pyc
�

|�egK���dZddlmZddlmZddlmZmZddlm	Z	m
Z
ddlmZm
Z
dgZd�Zd	Zd
Zd�ZGd�de�ZGd
�de�Zy)z�
    pygments.formatters.latex
    ~~~~~~~~~~~~~~~~~~~~~~~~~

    Formatter for LaTeX fancyvrb output.

    :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�)�StringIO)�	Formatter)�Lexer�
do_insertions)�Token�STANDARD_TYPES)�get_bool_opt�get_int_opt�LatexFormatterc��|jdd�jdd�jdd�jdd|z�jdd|z�jdd	|z�jd
d|z�jdd
|z�jdd|z�jdd|z�jdd|z�jdd|z�jdd|z�jdd|z�jdd|z�jdd|z�jdd|z�jd d!|z�S)"N�\��{��}�z\%sZbs{}z\%sZob{}z\%sZcb{}�^z\%sZca{}�_z\%sZus{}�&z\%sZam{}�<z\%sZlt{}�>z\%sZgt{}�#z\%sZsh{}�%z\%sZpc{}�$z\%sZdl{}�-z\%sZhy{}�'z\%sZsq{}�"z\%sZdq{}�~z\%sZti{})�replace)�text�
commandprefixs  �;/usr/lib/python3/dist-packages/pygments/formatters/latex.py�
escape_texr#s,���<�<��f�%����V�$����V�$�����m� ;�<�����m� ;�<�����m� ;�<����[�=�8�9����[�=�8�9����[�=�8�9����[�=�8�9����[�=�8�9����[�=�8�9����[�=�8�9����[�=�8�9����[�=�8�9����[�=�8�9����[�=�8�9����[�=�8�9�#:�z�
\documentclass{%(docclass)s}
\usepackage{fancyvrb}
\usepackage{color}
\usepackage[%(encoding)s]{inputenc}
%(preamble)s

%(styledefs)s

\begin{document}

\section*{%(title)s}

%(code)s
\end{document}
a�
\makeatletter
\def\%(cp)s@reset{\let\%(cp)s@it=\relax \let\%(cp)s@bf=\relax%%
    \let\%(cp)s@ul=\relax \let\%(cp)s@tc=\relax%%
    \let\%(cp)s@bc=\relax \let\%(cp)s@ff=\relax}
\def\%(cp)s@tok#1{\csname %(cp)s@tok@#1\endcsname}
\def\%(cp)s@toks#1+{\ifx\relax#1\empty\else%%
    \%(cp)s@tok{#1}\expandafter\%(cp)s@toks\fi}
\def\%(cp)s@do#1{\%(cp)s@bc{\%(cp)s@tc{\%(cp)s@ul{%%
    \%(cp)s@it{\%(cp)s@bf{\%(cp)s@ff{#1}}}}}}}
\def\%(cp)s#1#2{\%(cp)s@reset\%(cp)s@toks#1+\relax+\%(cp)s@do{#2}}

%(styles)s

\def\%(cp)sZbs{\char`\\}
\def\%(cp)sZus{\char`\_}
\def\%(cp)sZob{\char`\{}
\def\%(cp)sZcb{\char`\}}
\def\%(cp)sZca{\char`\^}
\def\%(cp)sZam{\char`\&}
\def\%(cp)sZlt{\char`\<}
\def\%(cp)sZgt{\char`\>}
\def\%(cp)sZsh{\char`\#}
\def\%(cp)sZpc{\char`\%%}
\def\%(cp)sZdl{\char`\$}
\def\%(cp)sZhy{\char`\-}
\def\%(cp)sZsq{\char`\'}
\def\%(cp)sZdq{\char`\"}
\def\%(cp)sZti{\char`\~}
%% for compatibility with earlier versions
\def\%(cp)sZat{@}
\def\%(cp)sZlb{[}
\def\%(cp)sZrb{]}
\makeatother
c��tj|�}|r|Sd}|�,|d|z}|j}tj|�}|��,||zS)N����)r�get�parent)�ttype�fname�anames   r"�_get_ttype_namer-�s^�����u�%�E�����E�
�-��b�	�E�!�������"�"�5�)���-��5�=�r$c�<�eZdZdZdZddgZdgZd�Zd�Zdd�Z	d	�Z
y
)ra�

    Format tokens as LaTeX code. This needs the `fancyvrb` and `color`
    standard packages.

    Without the `full` option, code is formatted as one ``Verbatim``
    environment, like this:

    .. sourcecode:: latex

        \begin{Verbatim}[commandchars=\\\{\}]
        \PY{k}{def }\PY{n+nf}{foo}(\PY{n}{bar}):
            \PY{k}{pass}
        \end{Verbatim}

    Wrapping can be disabled using the `nowrap` option.

    The special command used here (``\PY``) and all the other macros it needs
    are output by the `get_style_defs` method.

    With the `full` option, a complete LaTeX document is output, including
    the command definitions in the preamble.

    The `get_style_defs()` method of a `LatexFormatter` returns a string
    containing ``\def`` commands defining the macros needed inside the
    ``Verbatim`` environments.

    Additional options accepted:

    `nowrap`
        If set to ``True``, don't wrap the tokens at all, not even inside a
        ``\begin{Verbatim}`` environment. This disables most other options
        (default: ``False``).

    `style`
        The style to use, can be a string or a Style subclass (default:
        ``'default'``).

    `full`
        Tells the formatter to output a "full" document, i.e. a complete
        self-contained document (default: ``False``).

    `title`
        If `full` is true, the title that should be used to caption the
        document (default: ``''``).

    `docclass`
        If the `full` option is enabled, this is the document class to use
        (default: ``'article'``).

    `preamble`
        If the `full` option is enabled, this can be further preamble commands,
        e.g. ``\usepackage`` (default: ``''``).

    `linenos`
        If set to ``True``, output line numbers (default: ``False``).

    `linenostart`
        The line number for the first line (default: ``1``).

    `linenostep`
        If set to a number n > 1, only every nth line number is printed.

    `verboptions`
        Additional options given to the Verbatim environment (see the *fancyvrb*
        docs for possible values) (default: ``''``).

    `commandprefix`
        The LaTeX commands used to produce colored output are constructed
        using this prefix and some letters (default: ``'PY'``).

        .. versionadded:: 0.7
        .. versionchanged:: 0.10
           The default is now ``'PY'`` instead of ``'C'``.

    `texcomments`
        If set to ``True``, enables LaTeX comment lines.  That is, LaTex markup
        in comment tokens is not escaped so that LaTeX can render it (default:
        ``False``).

        .. versionadded:: 1.2

    `mathescape`
        If set to ``True``, enables LaTeX math mode escape in comments. That
        is, ``'$...$'`` inside a comment will trigger math mode (default:
        ``False``).

        .. versionadded:: 1.2

    `escapeinside`
        If set to a string of length 2, enables escaping to LaTeX. Text
        delimited by these 2 characters is read as LaTeX code and
        typeset accordingly. It has no effect in string literals. It has
        no effect in comments if `texcomments` or `mathescape` is
        set. (default: ``''``).

        .. versionadded:: 2.0

    `envname`
        Allows you to pick an alternative environment name replacing Verbatim.
        The alternate environment still has to support Verbatim's option syntax.
        (default: ``'Verbatim'``).

        .. versionadded:: 2.0
    �LaTeX�latex�texz*.texc��tj|fi|��t|dd�|_|j	dd�|_|j	dd�|_t|dd�|_tt|dd	��|_
tt|d
d	��|_|j	dd�|_t|dd�|_
|j	d
d�|_t|dd�|_t|dd�|_|j	dd�|_t%|j"�dk(r)|j"d|_|j"d	|_nd|_|j	dd�|_|j-�y)N�nowrapF�docclass�article�preambler&�linenos�linenostart��
linenostep�verboptions�nobackgroundr!�PY�texcomments�
mathescape�escapeinside�r�envname�Verbatim)r�__init__r	r3r(r4r6r7�absr
r8r:r;r<r!r>r?r@�len�left�rightrB�_create_stylesheet)�self�optionss  r"rDzLatexFormatter.__init__sL�����4�+�7�+�"�7�H�e�<������J�	�:��
����J��3��
�#�G�Y��>����{�7�M�1�E�F����k�'�<��C�D���"�;�;�}�b�9���(��.�%�H���$�[�[��$�?���'����F���&�w��e�D���#�K�K���;����t� � �!�Q�&��)�)�!�,�D�I��*�*�1�-�D�J� "�D���{�{�9�j�9������!r$c	���tdix}|_ix}|_|j}d�}|jD]�\}}t|�}d}|dr|dz
}|dr|dz
}|dr|dz
}|d	r|d
z
}|dr|dz
}|d
r|dz
}|dr|d||d�zz
}|dr|d||d��d||d��d�z
}n|dr|d||d�zz
}|dk(r��|j
d|�}|||<|||<��y)Nr&c��|r;djdD�cgc] }dt||||dzzd�dzz��"c}�Sycc}w)N�,)rrA�z%.2fr9�g�o@z1,1,1)�join�int)�col�is  r"�rgbcolorz3LatexFormatter._create_stylesheet.<locals>.rgbcolorsX����x�x�*3�!5�%&�"(�3�s�1�v��A��E�
�/B�B�+G�%�+O�!P�!5�6�6���!5s�%?�boldz\let\$$@bf=\textbf�italicz\let\$$@it=\textit�	underlinez\let\$$@ul=\underline�romanz\let\$$@ff=\textrm�sansz\let\$$@ff=\textsf�mono�colorz'\def\$$@tc##1{\textcolor[rgb]{%s}{##1}}�borderzG\def\$$@bc##1{{\setlength{\fboxsep}{\string -\fboxrule}\fcolorbox[rgb]{�}{�bgcolorz}{\strut ##1}}}zH\def\$$@bc##1{{\setlength{\fboxsep}{0pt}\colorbox[rgb]{%s}{\strut ##1}}}z$$)r�
ttype2name�cmd2defr!�styler-r)	rJ�t2n�c2d�cprUr*�ndef�name�cmndefs	         r"rIz!LatexFormatter._create_stylesheetsm��!&���+��d�o����d�l�
�
�
��	� �:�:�	�K�E�4�"�5�)�D��F��F�|��/�/���H�~��/�/���K� ��2�2���G�}��/�/���F�|��/�/���F�|��/�/���G�}��E�#�D��M�2�3�4���H�~��$�T�(�^�4�$�T�)�_�5�7�8���i���?�#�D��O�4�5�6����|���^�^�D�"�-�F��C��J��C��I�?	r$c
���|j}g}|jj�D] \}}|jd|�d|�d|�d���"t|jdj|�d�zS)z�
        Return the command sequences needed to define the commands
        used to format text in the verbatim environment. ``arg`` is ignored.
        z
\@namedef{z@tok@r^r�
)re�styles)r!ra�items�append�STYLE_TEMPLATErQ)rJ�argrerkrg�
definitions      r"�get_style_defszLatexFormatter.get_style_defsDsp��
�
�
���� $��� 2� 2� 4�	P��D�*��M�M��T�:�N�O�	P��t�'9�'9�+/�9�9�V�+<�!>�>�	>r$c��|j}|j}|jr|}t�}|js�|jd|jzdz�|jrE|j|j}}|jd|xrd|zxsdz|xrd|zxsdz�|js|js|jr|jd�|jr|jd|jz�|jd	�|D�]^\}}	|tjv�rV|jrU|	d
d}t!dt#|	��D]}
|d
|	|
k7rn
||	|
z
}�|	t#|�d}	t%||�}||	z}	�n|jrL|	j'd�}d
}t)|�D]\}
}
|st%|
|�||
<|}�dj+|�}	n�|jr�|	}d}	|r�|j-|j.�\}}}|rJ|j-|j0�\}}}|r|	t%||�|zz
}	n%|	t%||z|z|�z
}	n|	t%||�z
}	|r�}n+t%|	|�}	n|tj2vrt%|	|�}	g}|tur*	|j5||�|j:}|tur�*dj+t=|��}|rp|	j'd�}|ddD]0}|r|jd|�d|�d|�d��|jd��2|ds��.|jd|�d|�d|d�d����N|j|	���a|js!|jd|jzdz�|jr�|j>xsd}dddd�jA|jCdd�|�}jtDtG|jH|jJ|jL||jO�|jQ���z�yy#t6$r|j5t9|��Y���wxYw)Nz\begin{z}[commandchars=\\\{\}z
,numbers=leftz,firstnumber=%dr&z,stepnumber=%dz6,codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}rNz]
rr9rF�+rjr'r
rr^rz\end{z}
�utf8�latin1)�utf_8�latin_1�
iso_8859_1rr)r4r6�title�encoding�	styledefs�code))r`r!�fullrr3�writerBr7r8r:r?r>r@r;r�Comment�rangerFr#�split�	enumeraterQ�	partitionrGrH�Escaperm�KeyErrorr-r)�reversedrzr(r�DOC_TEMPLATE�dictr4r6ryrq�getvalue)rJ�tokensource�outfilercre�realoutfile�start�stepr*�valuerT�parts�in_math�partr �a�sep1�b�sep2rk�styleval�spl�linerzs                        r"�format_unencodedzLatexFormatter.format_unencodedPsD���o�o��
�
�
���9�9�!�K��j�G��{�{��M�M�*�t�|�|�3�6Q�Q�R��|�|�"�.�.����t���
�
�o�$�B�):�U�)B�H�b�J�#�?�(8�4�(?�E�2�G�H����$�"2�"2�d�6G�6G��
�
�8�9�����
�
�c�D�$4�$4�4�5��M�M�%� �'�;	%�L�E�5���
�
�%��#�#�!�!�A�J�E�"�1�c�%�j�1�*�� ��8�u�Q�x�/�!���q��)��*�
"�#�e�*�+�.�E�&�u�b�1�E�"�E�M�E��_�_�!�K�K��,�E�#�G�#,�U�#3�.���4�&�'1�$��';�E�!�H�&-�+��.� �H�H�U�O�E��&�&� �D��E��(,���t�y�y�(A�
��4���,0�N�N�4�:�:�,F�M�A�t�T�#� %��A�r�):�Q�)>� >�� %��A��H�q�L�"�)E� E��!�Z��2�%6�6�E��'�u�b�1�E��e�l�l�*�"�5�"�-���F��u�$�:��M�M�#�e�*�-�����
�u�$��x�x��� 0�1�H���k�k�$�'�����H�(�D���
�
��H�d�&K�L��M�M�$�'�(��r�7��M�M�B��#�b�'�"J�K��
�
�e�$�w;	%�z�{�{��M�M�(�T�\�\�1�E�9�:��9�9��}�}�.��H� �#�&���c�(�"�"�3��,�h�7�	
�

���l�����!%���!%���!)�!%�!4�!4�!6�!(�!1�!1�!3�5�5�
6���' �:��M�M�/�%�"8�9�:�s�:Q�#Q<�;Q<N)r&)�__name__�
__module__�__qualname__�__doc__rg�aliases�	filenamesrDrIrqr��r$r"rr�s7��g�P�D����G��	�I�"�.+�Z
>�e6r$c�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�LatexEmbeddedLexera�
    This lexer takes one lexer as argument, the lexer for the language
    being formatted, and the left and right delimiters for escaped text.

    First everything is scanned using the language lexer to obtain
    strings and comments. All other consecutive tokens are merged and
    the resulting text is scanned for escaped segments, which are given
    the Token.Escape type. Finally text that is not escaped is scanned
    again with the language lexer.
    c�Z�||_||_||_tj|fi|��y�N)rGrH�langrrD)rJrGrHr�rKs     r"rDzLatexEmbeddedLexer.__init__�s(����	���
���	�
���t�'�w�'r$c�@�d}g}g}|j|�D]B\}}}|�&|r|jt|�|f�g}||z
}�/|j|||f��D|r|jt|�|f�t||jj|��S)Nr&)�_find_safe_escape_tokensrmrFrr��get_tokens_unprocessed)rJr �buffered�
insertions�
insertion_bufrT�t�vs        r"r�z)LatexEmbeddedLexer.get_tokens_unprocessed�s������
��
��4�4�T�:�	0�G�A�q�!��y� ��%�%�s�8�}�m�&D�E�$&�M��A�
���$�$�a��A�Y�/�	0�����s�8�}�m�<�=��Z�!�Y�Y�=�=�h�G�I�	Ir$c#��K�|j|jj|�d��D]4\}}}|�%|j|�D]\}}}||z||f����.|d|f���6y�w)z8 find escape tokens that are not in strings or comments c�N�|tjvxs|tjvSr�)rr�String)r�s r"�<lambda>z=LatexEmbeddedLexer._find_safe_escape_tokens.<locals>.<lambda>�s��a�5�=�=�(�=�A����,=�r$N)�
_filter_tor�r��_find_escape_tokens)rJr rTr�r��i2�t2�v2s        r"r�z+LatexEmbeddedLexer._find_safe_escape_tokens�s~��������I�I�,�,�T�2�=�
�	!�G�A�q�!��y�"&�":�":�1�"=�)�J�B��B��b�&�"�b�.�(�)���q�j� �	!�s�A%A'c#�K�d}d}|D]*\}}}||�r|r	|d|f��d}|||f���"|s|}||z
}�,|r|d|f��yy�w)zC Keep only the tokens that match `pred`, merge the others together r&rNr�)rJ�it�pred�buf�idxrTr�r�s        r"r�zLatexEmbeddedLexer._filter_to�sr���������		�G�A�q�!��A�w���t�S�.�(��C���A�g�
���C��q���		���t�S�.� ��s�?Ac#�K�d}|r�|j|j�\}}}|r|d|f��|t|�z
}|r�|j|j�\}}}|rH|t|�ztj
|f��|t|�t|�zt|�zz
}n%|tj|f��|t|�z
}|}|r��yy�w)z; Find escape tokens within text, give token=None otherwise rN)r�rGrFrHrr��Error)rJr �indexr�r�r�r�s       r"r�z&LatexEmbeddedLexer._find_escape_tokens�s�������� �N�N�4�9�9�5�M�A�t�T���T�1�n�$���Q����� $���t�z�z� :�
��4����#�d�)�+�U�\�\�1�<�<��S��Y��Q��/�#�d�)�;�;�E�����d�2�2��S��Y�&�E��D��s�C
C�CN)	r�r�r�r�rDr�r�r�r�r�r$r"r�r��s!��	�(�I�&
!�!�"r$r�N)r��ior�pygments.formatterr�pygments.lexerrr�pygments.tokenrr�
pygments.utilr	r
�__all__r#r�rnr-rr�r�r$r"�<module>r�s\����(�/�0�3��
��:�*��n"��J	�b6�Y�b6�J	Q��Qr$