
    5h.                     `    S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	J
r
Jr  S/r " S S\5      rg)	z
pygments.formatters.rtf
~~~~~~~~~~~~~~~~~~~~~~~

A formatter that generates RTF files.

:copyright: Copyright 2006-2025 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RtfFormatterc                       \ rS rSrSrSrS/rS/rS rS r	S r
\S	 5       rS
 rS r\S 5       r\S 5       r\S 5       rS rSrg)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
RTFrtfz*.rtfc                    [         R                  " U 40 UD6  UR                  S5      =(       d    SU l        [	        USS5      U l        [        USS5      U l        [	        USU R
                  5      U l        [	        USS	5      U l	        [        [	        US
S5      5      U l        [        [	        USS5      5      U l        [        USS5      U l        UR                  SS5      U l        U R                  (       d  U R                  R                   U l        / U l        [%        US/ 5       HL  n ['        U5      nU R                  (       a  X R                  -
  S-   nU R"                  R)                  U5        MN     UR                  SS5      U l        U R,                  (       dD  U R                  R.                  S:X  a  [0        S   U l        OU R                  R.                  U l        U R3                  5       U l        g! [*         a     M  f = f)aR  
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...

fontface fontsizer   linenosFlineno_fontsizelineno_padding   linenostart   
linenostephl_linenostarthl_colorhl_lineslineno_colorinheritansibrightblackN)r   __init__getr   r   r   r   r   r   r   absr   r   r   r   stylehighlight_colorr   r   intappend
ValueErrorr   line_number_colorr   _create_color_mappingcolor_mapping)selfoptionslinenos      b/var/www/html/cementerio_25MayoBackend/env/lib/python3.13/site-packages/pygments/formatters/rtf.pyr    RtfFormatter.__init__i   s    	4+7+J/52#GZ;#GY>*74E+/== :)'3CQG{7M1EFk'<CD*74DeLJ3}} JJ66DM"7J;FV&&#&6&66:F$$V, < $KK;  

,,	9 %-->$?! %)JJ$@$@!!779  s   ,AG::
HHc                 f    UR                  SS5      R                  SS5      R                  SS5      $ )N\z\\{z\{}z\})replace)r+   texts     r.   _escapeRtfFormatter._escape   s-    ||D&)GC'GC'	(    c                 |   U(       d  gU R                  U5      n/ nU H{  n[        U5      nUS:  a  UR                  [        U5      5        M0  SUs=::  a  S:  a  O  OUR                  SU-  5        MV  SU::  d  M^  UR                  S[	        U5      -  5        M}     SR                  U5      R                  SS5      $ )Nr      i   z{\u%d}z{\u%d}{\u%d}
z\par)r6   ordr&   strr	   joinr4   )r+   r5   bufccns        r.   _escape_textRtfFormatter._escape_text   s     ||D!AQBT{

3q6"2''

9r>*B 

+mB.??@  wws|##D'22r8   c                 |    U S   S:X  a  U SS  n S[        U SS S5      [        U SS S5      [        U SS S5      4-  $ )	Nr   #r   z\red%d\green%d\blue%d;r            )r%   )	hex_colors    r.   hex_to_rtf_colorRtfFormatter.hex_to_rtf_color   s[    Q<3!!"I*IaNB/IaNB/IaNB/.  	r8   c              #      #    U HX  u  p#US:X  a  X#4v   M  SU;   a;  UR                  S5      nUSS  H  nX%S-   4v   M     US   (       a
  X$S   4v   MQ  MS  X#4v   MZ     g7f)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.
r;   N)split)r+   tokensourcettypevaluelineslines         r.   _split_tokens_on_newlines&RtfFormatter._split_tokens_on_newlines   sw      (LE}n$D)!#2JD t),, '9 ),,  n$ (s   A A"c                 4   [        5       nSnU R                  (       a  X!U R                  '   US-  nU R                  (       a  X!U R                  '   US-  nU R
                   H3  u  p4US   US   US   4 H  nU(       d  M  XQ;  d  M  X!U'   US-  nM     M5     U$ )zN
Create a mapping of style hex colors to index/offset in
the RTF color table.
r   colorbgcolorborder)r   r   r   r   r   r#   )r+   r*   offset_r#   rW   s         r.   r)   "RtfFormatter._create_color_mapping   s    
 $<</5$++,aKF==+1$--(aKF

HAwy)95?J5U7+1%(aKF K # r8   c                 $   U R                   U R                  :w  aA  SR                  U R                   U R                  U R                     SU R
                  -  5      $ SR                  U R                  U R                     SU R
                  -  5      $ )Nz{{\fs{} \cf{} %s{}}} z{{\cf{} %s{}}})r   r   formatr*   r   r   r+   s    r.   _lineno_templateRtfFormatter._lineno_template   s    4==0+2243G3G,,T->->? 3 335 5 !''(:(:4;L;L(MD///1 	1r8   c                 <    SU R                   U R                      S3$ )Nz{\highlightr^   )r*   r   r`   s    r.   _hl_open_strRtfFormatter._hl_open_str   s!    t11$--@ACCr8   c                    / nUR                  SU R                  =(       a    SU R                  U R                  5      -   =(       d    S-  5        UR                  S5        U R                  R	                  5        H%  u  p#UR                  U R                  U5      5        M'     UR                  S5        UR                  S5        U R                  (       a  UR                  SU R                  -  5        UR                  S5        U$ )	Nz?{\rtf1\ansi\uc0\deff0{\fonttbl{\f0\fmodern\fprq1\fcharset0%s;}}r^   r   z{\colortbl;r3   z\f0\sa0z\fs%dz\dntblnsbdb)r&   r   r6   r*   itemsrJ   r   )r+   rR   rW   r[   s       r.   _rtf_headerRtfFormatter._rtf_header   s     G 6#,,t}}5+6 <9;= 	> 	^$**002HELL..u56 3S 	[!==LLDMM12
 	^$r8   c                 l   U R                    H  nUR                  US-   5        M     U R                  U5      nU R                  (       ac  Sn/ nU H4  u  pgUR	                  Xg45        UR                  S5      (       d  M/  US-  nM6     [        [        X@R                  -   S-
  5      5      nUnSn	Sn
U GH  u  pgU
(       a*  XR                  ;   a  UR                  U R                  5        U
(       a  U R                  (       a}  XR                  -
  S-   U R                  -  S:X  a,  XR                  -   S-
  n[        U5      R                  W5      nOSR                  W5      nUR                  U R                  U-  5        U R                  R                  U5      (       dP  UR                   (       a?  UR                   nU R                  R                  U5      (       d  UR                   (       a  M?  U R                  R#                  U5      n/ nUS   (       a$  UR	                  SU R$                  US      -  5        US   (       a$  UR	                  S	U R$                  US      -  5        US
   (       a  UR	                  S5        US   (       a  UR	                  S5        US   (       a  UR	                  S5        US   (       a$  UR	                  SU R$                  US      -  5        SR'                  U5      nU(       a  UR                  SU S35        UR                  U R)                  U5      5        U(       a  UR                  S5        Sn
UR                  S5      (       d  GM  XR                  ;   a  UR                  S5        UR                  S5        Sn
U	S-  n	GM     UR                  S5        g )Nr;   r   r   Tr   rX   z\cb%drW   z\cf%dboldz\bitalicz\i	underlinez\ulrY   z\chbrdr\chcfpat%dr2   r^   r3   Fz}
)rh   writerT   r   r&   endswithlenr=   r   r   rd   r   rjustra   r#   styles_tokenparentstyle_for_tokenr*   r>   rB   )r+   rO   outfilerS   
line_counttokensrP   rQ   linenos_widthr-   start_new_linecurrent_lineno
lineno_strr#   r?   starts                   r.   format_unencodedRtfFormatter.format_unencoded  s   $$DMM$+& % 44[A <<JF +un->>$''!OJ !,  J/?/?$?$A BCM K 'LE&MM"9d//0$,,+++A-t>!C%+.>.>%>%BN!$^!4!:!:=!IJ!#-!8Jd33j@Ajj--e44 jj--e44JJ..u5ECY

8d&8&8y9I&JJKW~

8d&8&8w&HHIV}

5!X

5![!

6"X

0--eHo>? @GGCLE5'm,MM$++E23c""N ~~d##]]*MM#&d#!%!] (` 	er8   )r*   r   r   r   r   r   r   r   r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__namealiases	filenamesr    r6   rB   staticmethodrJ   rT   r)   propertyra   rd   rh   r}   __static_attributes__ r8   r.   r
   r
      s    O` DgG	I0:d(
30  %$0 1 1 D D  4Gr8   N)r   collectionsr   pygments.formatterr   pygments.styler   pygments.utilr   r   r   r	   __all__r
   r   r8   r.   <module>r      s3    $ ( # P P 
I9 Ir8   