h.hdZddlmZddlmZddlmZddlmZm Z m Z m Z dgZ GddeZ dS) z pygments.formatters.rtf ~~~~~~~~~~~~~~~~~~~~~~~ A formatter that generates RTF files. :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. ) OrderedDict) Formatter)_ansimap) get_bool_opt get_int_opt get_list_opt surrogatepair RtfFormatterceZdZdZdZdgZdgZdZdZdZ e dZ d Z d Z ed Zed Zed ZdZdS)r a Format tokens as RTF markup. This formatter automatically outputs full RTF documents with color information and other useful stuff. Perfect for Copy and Paste into Microsoft(R) Word(R) documents. Please note that ``encoding`` and ``outencoding`` options are ignored. The RTF format is ASCII natively, but handles unicode characters correctly thanks to escape sequences. .. versionadded:: 0.6 Additional options accepted: `style` The style to use, can be a string or a Style subclass (default: ``'default'``). `fontface` The used font family, for example ``Bitstream Vera Sans``. Defaults to some generic font which is supposed to have fixed width. `fontsize` Size of the font used. Size is specified in half points. The default is 24 half-points, giving a size 12 font. .. versionadded:: 2.0 `linenos` Turn on line numbering (default: ``False``). .. versionadded:: 2.18 `lineno_fontsize` Font size for line numbers. Size is specified in half points (default: `fontsize`). .. versionadded:: 2.18 `lineno_padding` Number of spaces between the (inline) line numbers and the source code (default: ``2``). .. versionadded:: 2.18 `linenostart` The line number for the first line (default: ``1``). .. versionadded:: 2.18 `linenostep` If set to a number n > 1, only every nth line number is printed. .. versionadded:: 2.18 `lineno_color` Color for line numbers specified as a hex triplet, e.g. ``'5e5e5e'``. Defaults to the style's line number color if it is a hex triplet, otherwise ansi bright black. .. versionadded:: 2.18 `hl_lines` Specify a list of lines to be highlighted, as line numbers separated by spaces, e.g. ``'3 7 8'``. The line numbers are relative to the input (i.e. the first line is line 1) unless `hl_linenostart` is set. .. versionadded:: 2.18 `hl_color` Color for highlighting the lines specified in `hl_lines`, specified as a hex triplet (default: style's `highlight_color`). .. versionadded:: 2.18 `hl_linenostart` If set to ``True`` line numbers in `hl_lines` are specified relative to `linenostart` (default ``False``). .. versionadded:: 2.18 RTFrtfz*.rtfc tj|fi||dpd|_t |dd|_t |dd|_t |d|j|_t |dd |_ tt |d d |_ tt |d d |_ t |d d|_ |dd|_|js|jj|_g|_t%|dgD]P} t'|}|j r ||j z d z}|j|A#t*$rYMwxYw|dd|_|js4|jjdkrt0d|_n|jj|_||_dS)a Additional options accepted: ``fontface`` Name of the font used. Could for example be ``'Courier New'`` to further specify the default which is ``'\fmodern'``. The RTF specification claims that ``\fmodern`` are "Fixed-pitch serif and sans serif fonts". Hope every RTF implementation thinks the same about modern... fontfacefontsizerlinenosFlineno_fontsizelineno_padding linenostart linenostephl_linenostarthl_colorhl_lines lineno_colorinheritansibrightblackN)r__init__getrrrrrrrabsrrrrstylehighlight_colorrrintappend ValueErrorrline_number_colorr_create_color_mapping color_mapping)selfoptionslinenos /builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/pygments/formatters/rtf.pyrzRtfFormatter.__init__is 4++7+++ J//52 #GZ;; #GY>> *74E+/= : :)'3CQGG{7M1EEFFk'<CCDD*74DeLL J33 } 7 J6DM "7J;;  F V&;#d&66:F $$V,,,,    $KK;;  A , 99%-->$?!!%)J$@!!7799s6=E44 FFc~|ddddddS)N\z\\{z\{}z\})replace)r*texts r-_escapezRtfFormatter._escapes6||D&))GC''GC'' (c|sdS||}g}|D]}t|}|dkr#|t|:d|cxkrdkrnn|d|zcd|kr%|dt |zd|ddS)Nriz{\u%d}z {\u%d}{\u%d} z\par)r4ordr%strr joinr2)r*r3bufccns r- _escape_textzRtfFormatter._escape_texts 2||D!! A AAQBT{{ 3q66""""2''''''''' 9r>****B +mB.?.??@@@wws||##D'222r5c|ddkr |dd}dt|dddt|dddt|dddfzS) Nr#rz\red%d\green%d\blue%d;r)r$) hex_colors r-hex_to_rtf_colorzRtfFormatter.hex_to_rtf_colorso Q<3  !!"" I*IacNB//IacNB//IacNB//. r5c#K|D]\\}}|dkr||fVd|vr@|d}|ddD] }||dzfV |dr ||dfVV||fV]dS)z Split tokens containing newline characters into multiple token each representing a line of the input file. Needed for numbering lines of e.g. multiline comments. r8N)split)r* tokensourcettypevaluelineslines r-_split_tokens_on_newlinesz&RtfFormatter._split_tokens_on_newliness ( % %LE5}}en$$$$ D))!#2#J--D $t),,,,,9- %),,,,en$$$$ % %r5ct}d}|jr|||j<|dz }|jr|||j<|dz }|jD]/\}}|d|d|dfD]}|r||vr |||<|dz }0|S)zf Create a mapping of style hex colors to index/offset in the RTF color table. rcolorbgcolorborder)rrrrrr")r*r)offset_r"rQs r-r(z"RtfFormatter._create_color_mappings $  < /5M$+ , aKF = +1M$- ( aKF   HAuwy)95?J   U-77+1M%(aKF r5c|j|jkr4d|j|j|jd|jzSd|j|jd|jzS)Nz{{\fs{} \cf{} %s{}}} z{{\cf{} %s{}}})rrformatr)rrr*s r-_lineno_templatezRtfFormatter._lineno_templatesz  4= 0 0+2243G,T->? 3355 5!''(:4;L(MD//11 1r5c.d|j|jdS)Nz {\highlightrW)r)rrYs r- _hl_open_strzRtfFormatter._hl_open_strsCt1$-@CCCCr5cg}|d|jrd||jzpdz|d|jD]-\}}|||.|d|d|jr|d|jz|d|S) Nz?{\rtf1\ansi\uc0\deff0{\fonttbl{\f0\fmodern\fprq1\fcharset0%s;}}rWrz {\colortbl;r1z\f0\sa0z\fs%dz \dntblnsbdb)r%rr4r)itemsrFr)r*rMrQrUs r- _rtf_headerzRtfFormatter._rtf_headers  G 6#,,t}55+6<9;= > > >  ^$$$*0022 7 7HE1 LL..u55 6 6 6 6 S  [!!! = 3 LLDM1 2 2 2  ^$$$ r5c|jD]}||dz||}|jrfd}g}|D]6\}}|||f|dr|dz }7t t||jzdz }|}d} d} |D]\}}| r#| |j vr||j | r|jr{| |jz dz|j zdkr0| |jzdz } t|  |} nd |} ||j | z|j|s/|jr(|j}|j|s|j(|j|} g}| dr)|d|j| dz| dr)|d |j| dz| d r|d | d r|d | dr|d| dr)|d|j| dzd|}|r|d|d||||r|dd} |dr:| |j vr|d|dd} | dz } |ddS)Nr8rrTrrRz\cb%drQz\cf%dboldz\bitalicz\i underlinez\ulrSz\chbrdr\chcfpat%dr0rWr1Fz} )r_writerOrr%endswithlenr:rrr\rrjustrZr" styles_tokenparentstyle_for_tokenr)r;r?)r*rJoutfilerN line_counttokensrKrL linenos_widthr,start_new_linecurrent_lineno lineno_strr"r<starts r-format_unencodedzRtfFormatter.format_unencodeds$ ' 'D MM$+ & & & &44[AA  < !JF + $ $ u uen--->>$''$!OJ Jt/?$?$A B BCCM K'. . LE5 1&DM"9"9 d/000 B$, B4++A-t>!CC%+d.>%>%BN!$^!4!4!:!:=!I!IJJ!#-!8!8J d3j@AAAj--e44 % % j--e44 % %J..u55ECY L 8d&8y9I&JJKKKW~ J 8d&8w&HHIIIV} " 5!!!X " 5!!![! # 6"""X @ 0-eHo>?@@@GGCLLE - m5mmm,,, MM$++E22 3 3 3 # c""""N~~d## T]**MM#&&& d###!%!  er5N)__name__ __module__ __qualname____doc__namealiases filenamesrr4r? staticmethodrFrOr(propertyrZr\r_rsr5r-r r sOO` DgG I0:0:0:d((( 3330\%%%$011X1DDXDX4GGGGGr5N)rw collectionsrpip._vendor.pygments.formatterrpip._vendor.pygments.stylerpip._vendor.pygments.utilrrrr __all__r r}r5r-rs$#####444444//////\\\\\\\\\\\\  IIIII9IIIIIr5