hjKdZddlmZddlmZddlmZmZddlm Z m Z ddl m Z m Z dgZdZd Zd Zd ZGd deZGd deZdS)z pygments.formatters.latex ~~~~~~~~~~~~~~~~~~~~~~~~~ Formatter for LaTeX fancyvrb output. :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. )StringIO) Formatter)Lexer do_insertions)TokenSTANDARD_TYPES) get_bool_opt get_int_optLatexFormattercN|dddddddd|ddd|ddd|d d d|d d d|d dd|ddd|ddd|ddd|ddd|ddd|ddd|ddd|ddd|dd d|d!S)"N\{}zZbs{}zZob{}zZcb{}^zZca{}_zZus{}&zZam{}zZgt{}#zZsh{}%zZpc{}$zZdl{}-zZhy{}'zZsq{}"zZdq{}~zZti{})replace)text commandprefixs /builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/pygments/formatters/latex.py escape_texr#s <<f % %V$$V$$ ;] ; ; ;<< ;] ; ; ;<< ;] ; ; ;<<8-888998-888998-888998-888998-888998-888998-888998-888998-888998-888998-888998-88899#: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 ctj|}|r|Sd}|(|d|z}|j}tj|}|(||zS)N)rgetparent)ttypefnameanames r"_get_ttype_namer-sa  u % %E  E -b E! "5)) - 5=r$c>eZdZdZdZddgZdgZdZdZd d Z d Z d S) 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 LaTeXlatextexz*.texc tj|fi|t|dd|_|dd|_|dd|_t|dd|_tt|dd |_ tt|d d |_ |d d|_ t|d d|_ |d d|_t|dd|_t|dd|_|dd|_t%|jdkr%|jd|_|jd |_nd|_|dd|_|dS)NnowrapFdocclassarticlepreambler&linenos linenostart linenostep verboptions nobackgroundr!PY texcomments mathescape escapeinsiderenvnameVerbatim)r__init__r r3r(r4r6r7absr r8r:r;r<r!r>r?r@lenleftrightrB_create_stylesheet)selfoptionss r"rDzLatexFormatter.__init__s4++7+++"7He<<  J ::  J33 #GY>> {7M1EEFFk'<CCDD";;}b99(.%HH$[[$??'FF&w eDD#KK;; t ! !Q & &)!,DI*1-DJJ "D {{9j99  !!!!!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||dz }|dr8|d||d||dz }n/|dr'|d||dz }|dkr |d|}|||<|||<-dS)Nr&cNr!dfddDSdS)N,c `g|]*}dt||dzzddz z+S)z%.2fr9go@)int).0icols r" zGLatexFormatter._create_stylesheet..rgbcolor..sN!5!5!5%&"(3s1vAE /BB+G+G%+O!P!5!5!5r$)rrAz1,1,1)join)rTs`r"rgbcolorz3LatexFormatter._create_stylesheet..rgbcolorsN xx!5!5!5!5*3!5!5!5666wr$boldz\let\$$@bf=\textbfitalicz\let\$$@it=\textit underlinez\let\$$@ul=\underlineromanz\let\$$@ff=\textrmsansz\let\$$@ff=\textsfmonocolorz-\def\$$@tc##1{{\textcolor[rgb]{{{}}}{{##1}}}}borderzj\def\$$@bc##1{{{{\setlength{{\fboxsep}}{{\string -\fboxrule}}\fcolorbox[rgb]{{{}}}{{{}}}{{\strut ##1}}}}}}bgcolorzT\def\$$@bc##1{{{{\setlength{{\fboxsep}}{{0pt}}\colorbox[rgb]{{{}}}{{\strut ##1}}}}}}z$$)r ttype2namecmd2defr!styler-formatr) rJt2nc2dcprXr*ndefnamecmndefs r"rIz!LatexFormatter._create_stylesheets!& +dodl      :  KE4"5))DFF| 0//H~ 0//K  322G} 0//F| 0//F| 0//G} mKRRS[S[\`ah\iSjSjkklH~ hLLRFS[S[\`ai\jSkSk$HT)_55M7M78i hEEKVHHUYZcUdLeLeEfEfh||^^D"--FCJCII9  r$r&c |j}g}|jD]$\}}|d|d|d|d%t|jd|dzS)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 )rhstyles)r!rcitemsappendSTYLE_TEMPLATErW)rJargrhrorj definitions r"get_style_defszLatexFormatter.get_style_defsAs   $ 2 2 4 4 L L D* MMJJJ$JJJJJJ K K K Kt'9+/99V+<+<!>!>> >r$c > |j}|j}|jr|}t}|js|d|jzdz|jr7|j|j }}|d|rd|zpdz|rd|zpdz|j s|j s|j r|d|j r|d|j z|d |D]\}} |tjvr|j rw| d d }t!d t#| D]!} |d | | krn || | z }"| t#|d} t%||}|| z} n$|j rZ| d } d } t)| D]\} } | st%| || | <| } d | } n|j r| }d} |r||j\}}}|rQ||j\}}}|r| t%|||zz } n-| t%||z|z|z } n| t%||z } |n/t%| |} n|tjvrt%| |} g}|tur_ |||n2#t6$r%|t9|YnwxYw|j}|tu_dt=|}|r| d}|ddD]8}|r|d|d|d|d|d9|dr%|d|d|d|dd|| |js |d|jzdz|jr|jpd}dddd |!dd|}|tDtG|j$|j%|j&||'|(zdSdS)Nz\begin{z}[commandchars=\\\{\}z ,numbers=leftz,firstnumber=%dr&z,stepnumber=%dz6,codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}rNz] rr9rF+rnr'r rrmrz\end{z} utf8latin1)utf_8latin_1 iso_8859_1rr)r4r6titleencoding styledefscode))rbr!fullrr3writerBr7r8r:r?r>r@r;rCommentrangerFr#split enumeraterW partitionrGrHEscaperqKeyErrorr-r)reversedr~r(r DOC_TEMPLATEdictr4r6r}rugetvalue)rJ tokensourceoutfilerfrh realoutfilestartstepr*valuerSpartsin_mathpartr asep1bsep2rostylevalsplliner~s r"format_unencodedzLatexFormatter.format_unencodedMso   9 !!KjjG{ ! MM*t|36QQ R R R| H".t o$B):U)BHbJ#?(84(?E2GHHH 9$"2 9d6G 9 8999 6 cD$44555 MM% '; %; %LE5 %%#$2!!A#JE"1c%jj11** 8uQx//!Eq)!#e**++.E&ub11E"EMEE_2!KK,,E#G#,U#3#3..4&<'1$';';E!H&-+HHUOOEE&2 DE 7(,ty(A(A 47,0NN4:,F,FMAtT#F %Ar):):Q)> > %AHqL")E)E E!Z2%6%66E 7'ub11EEel**"5"--Fu$$:MM#e*----:::MM/%"8"899999:  u$$xx 0 011H %kk$''H((DI &G2&G&G&G&Gt&G&G&GHHHMM$''''r7HMM"Fr"F"FX"F"F3r7"F"F"FGGG e$$$${ ; MM(T\1E9 : : : 9 6}.H #&c(""3,,h77    l!%!%!)!%!4!4!6!6!(!1!1!3!3 5555 6 6 6 6 6 6 6s3K,K>=K>N)r&) __name__ __module__ __qualname____doc__rjaliases filenamesrDrIrurr$r"r r sggP DG I""".(((T > > > >e6e6e6e6e6r$c0eZdZdZdZdZdZdZdZdS)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 T||_||_||_tj|fi|dSN)rGrHlangrrD)rJrGrHrrKs r"rDzLatexEmbeddedLexer.__init__s5    t''w'''''r$crd}g}g}||D]N\}}}|.|r&|t||fg}||z }6||||fO|r$|t||ft||j|S)Nr&)_find_safe_escape_tokensrqrFrrget_tokens_unprocessed)rJr buffered insertions insertion_bufrStvs r"rz)LatexEmbeddedLexer.get_tokens_unprocesseds  44T:: 0 0GAq!y '%%s8}}m&DEEE$&MA $$aAY////  >   s8}}m< = = =Z!Y==hGGII Ir$c#K||j|dD]6\}}}|'||D]\}}}||z||fV/|d|fV7dS)z8 find escape tokens that are not in strings or comments c:|tjvp |tjvSr)rrString)rs r"z=LatexEmbeddedLexer._find_safe_escape_tokens..sa5=(=A,=r$N) _filter_torr_find_escape_tokens)rJr rSrri2t2v2s r"rz+LatexEmbeddedLexer._find_safe_escape_tokenss I , ,T 2 2 = =   ! !GAq!y"&":":1"="=))JBBb&"b.(((()qj     ! !r$c#Kd}d}|D]-\}}}||r|r |d|fVd}|||fV$|s|}||z }.|r |d|fVdSdS)zC Keep only the tokens that match `pred`, merge the others together r&rNr)rJitpredbufidxrSrrs r"rzLatexEmbeddedLexer._filter_tos  GAq!tAww tS.(((CAg Cq  !tS.  ! !r$c#Kd}|r||j\}}}|r|d|fV|t|z }|r||j\}}}|rT|t|ztj|fV|t|t|zt|zz }n%|tj|fV|t|z }|}|dSdS)z; Find escape tokens within text, give token=None otherwise rN)rrGrFrHrrError)rJr indexrrrrs r"rz&LatexEmbeddedLexer._find_escape_tokenss  NN4955MAtT T1n$$$Q  $tz : : 4#d))+U\1<<<<SYYQ/#d));;EEd2222SYY&ED     r$N) rrrrrDrrrrrr$r"rrsl  ((( III& ! ! !!!!"r$rN)riorpip._vendor.pygments.formatterrpip._vendor.pygments.lexerrrpip._vendor.pygments.tokenrrpip._vendor.pygments.utilr r __all__r#rrrr-r rrr$r"rs&444444;;;;;;;;<<<<<<<<????????  :::* n"J   _6_6_6_6_6Y_6_6_6D QQQQQQQQQQr$