o
    5d                     @   sB   d Z ddlZddlmZ ddlmZmZ dgZG dd deZdS )z
    pygments.formatters.groff
    ~~~~~~~~~~~~~~~~~~~~~~~~~

    Formatter for groff output.

    :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    N)	Formatter)get_bool_optget_int_optGroffFormatterc                   @   sX   e Zd ZdZdZg dZg Zdd Zdd Zdd	 Z	d
d Z
dd Zdd Zdd ZdS )r   a  
    Format tokens with groff escapes to change their color and font style.

    .. versionadded:: 2.11

    Additional options accepted:

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

    `monospaced`
        If set to true, monospace font will be used (default: ``true``).

    `linenos`
        If set to true, print the line numbers (default: ``false``).

    `wrap`
        Wrap lines to the specified number of characters. Disabled if set to 0
        (default: ``0``).
    groff)r   ZtroffZroffc                 K   sZ   t j| fi | t|dd| _t|dd| _d| _t|dd| _d| _i | _	| 
  d S )N
monospacedTlinenosFr   wrap)r   __init__r   r   r   _linenor   r	   _linelenstyles_make_styles)selfoptions r   |C:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\pip/_vendor/pygments/formatters/groff.pyr
   -   s   zGroffFormatter.__init__c                 C   s   | j rdnd}| j rdnd}| j rdnd}| jD ]G\}}d }}|d r0|d	|d  7 }d
| }|d r<||7 }|| }|d rH||7 }|| }|d rX|d|d  7 }d| }||f| j|< qd S )Nz\f[CR]z\f[R]z\f[CB]z\f[B]z\f[CI]z\f[I] colorz\m[%s]z\m[]bolditalicbgcolorz\M[%s]z\M[])r   styler   )r   Zregularr   r   ttypendefstartendr   r   r   r   :   s&   zGroffFormatter._make_stylesc                 C   sX   t  }| jD ]\}}|d d ur||d  q|D ]}|d| d | d  qd S )Nr   z
.defcolor z rgb #
)setr   addwrite)r   outfilecolors_r   r   r   r   r   _define_colorsQ   s   zGroffFormatter._define_colorsc                 C   s4   |  j d7  _ |d| j dkrdpd| j f  d S )N   z%s% 4d r   r   )r   r    )r   r!   r   r   r   _write_lineno[   s   &zGroffFormatter._write_linenoc                 C   s   t |d}| jrdnd}d}|| jkrStdt|| j D ]}||| j || j | j  }||d | 7 }q || j }|dkrQ||| d d  7 }|| _|S | j| | jkrfd| | }|| _|S |}|  j|7  _|S )Nr   z     r   r   r%   )lenrstripr   r	   rangemathfloorr   )r   linelengthspacenewlineichunk	remainderr   r   r   
_wrap_line`   s&   

zGroffFormatter._wrap_linec                 C   s   | dd dd dd dd d	d
}|}|D ]+}t|t| krE|d dd   dd }| |d|dd   d }q|S )N\z\[u005C].z	\[char46]'z\[u0027]`z\[u0060]~z\[u007E]unicode_escaper%   xZu00z\[u])replacer'   encodedecodeupper)r   textcopycharunir   r   r   _escape_charsw   s$   

zGroffFormatter._escape_charsc           	   	   C   s  |  | |d | jr| | |D ]j\}}|| jvr%|j}|| jvs| j| \}}|dD ]L}| jdkr=| |}|rY|rY| 	|
d}|dkrX|d|||f n|| 	|
d |dr}| jru| | d| _q1|d d| _q1q|d d S )Nz.nf
\f[CR]
Tr   r   r   z
.fi)r$   r    r   r&   r   parent
splitlinesr	   r3   rD   r(   joinendswithr   )	r   Ztokensourcer!   r   valuer   r   r,   r@   r   r   r   format_unencoded   s6   









zGroffFormatter.format_unencodedN)__name__
__module____qualname____doc__namealiases	filenamesr
   r   r$   r&   r3   rD   rJ   r   r   r   r   r      s    
)	rN   r*   Zpip._vendor.pygments.formatterr   pip._vendor.pygments.utilr   r   __all__r   r   r   r   r   <module>   s    
