Ë ØÚ ˆx¢©ãó–—dZddlmZddlmZddlmZmZddlm Z m Z ddl m 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\%sZgt{}Ú#z\%sZsh{}Ú%z\%sZpc{}Ú$z\%sZdl{}Ú-z\%sZhy{}Ú'z\%sZsq{}Ú"z\%sZdq{}Ú~z\%sZti{})Úreplace)ÚtextÚ commandprefixs ú>/usr/lib/python3.12/site-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„Zd d„Z d „Z y ) r a€ 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 d d«|_ 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 }|d r|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«dz z‘Œ"c}«Sycc}w)NÚ,)rrAéz%.2fr9égào@z1,1,1)ÚjoinÚint)ÚcolÚis r"Úrgbcolorz3LatexFormatter._create_stylesheet..rgbcolors]€ÙØ—x‘xÙ*3ó!5Ù*3 Qð"(¬3¨s°1©v¸¸AÀ¹E¹ Ñ/BÀBÓ+GÈ%Ñ+OÓ!PØ*3ñ!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_stylesheetsh€Ü!&¨  Ð+ˆˆ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_defsDsi€ð × Ñ ˆØˆØ $§ ¡ × 2Ñ 2Ö 4Ñ ˆD�*Ø �MŠMººTÂ:ÐNÕ Oð!5ä t×'9Ñ'9Ø+/¯9©9°VÓ+<ñ!>ñ>ð >r$c óþ—|j}|j}|jr |}t«}|jsâ|j d|j zdz«|jrE|j|j}}|j d|xrd|zxsdz|xrd|zxsdz«|js|js |jr|j d«|jr|j d|jz«|j d «|D�]^\}} |tjv�rV|jrU| d d }t!d t#| ««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|j d|›d|›d|›d�«|j d«Œ2|ds�Œ.|j d|›d|›d|d›d�«�ŒN|j | «�Œa|js!|j d|j zdz«|jr˜|j>xsd}ddddœjA|jCdd«|«}j tDtG|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_unencodedPs0€à�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¡Ñ)™ð2ð "¤# e£* +Ð.�EÜ& u¨bÓ1�Eð" E™M’EØ—_’_à!ŸK™K¨Ó,�EØ#�GÜ#,¨UÖ#3™˜˜4Ù&Ü'1°$¸Ó';˜E !™HØ&- +™ð$4ð Ÿ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"r r “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Ö:‰GˆAˆq�!؈yÙ Ø×%Ñ%¤s¨8£}°mÐ&DÔEØ$&�MؘA‘ ‘à×$Ñ$ a¨¨A YÕ/ð;ñ Ø × Ñ œ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"Úz=LatexEmbeddedLexer._find_safe_escape_tokens..à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Üstèø€à—‘Ø �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èsmèø€àˆØˆÛ‰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-r r£r¡r$r"ÚrÆs\ðñõå(ß/ß0ß3ð Ð €ò:ð*€ ðn"€òJ ôb6�Yôb6ôJ Q˜õQr$