U
    luf˜  ã                   @   sJ   d Z ddlmZ dgZedƒdedƒdiZefdd	„ZG d
d„ deƒZdS )zå
    pygments.formatters.pangomarkup
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Formatter for Pango markup output.

    :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é    )Ú	FormatterÚPangoMarkupFormatterú&z&amp;ú<z&lt;c                 C   s
   |   |¡S )z Escape & and < for Pango Markup.)Ú	translate)ÚtextÚtable© r	   úC/tmp/pip-unpacked-wheel-7eq1ciah/pygments/formatters/pangomarkup.pyÚescape_special_chars   s    r   c                   @   s0   e Zd ZdZdZddgZg Zdd„ Zdd„ Zd	S )
r   zk
    Format tokens as Pango Markup code. It can then be rendered to an SVG.

    .. versionadded:: 2.9
    zPango MarkupZpangoZpangomarkupc                 K   s¦   t j| f|Ž i | _| jD ]†\}}d}d}|d rJ|d|d  7 }d| }|d rb|d7 }d| }|d rz|d	7 }d
| }|d r’|d7 }d| }||f| j|< qd S )NÚ Úcolorz<span fgcolor="#%s">z</span>Zboldz<b>z</b>Zitalicz<i>z</i>Z	underlinez<u>z</u>)r   Ú__init__ÚstylesÚstyle)ÚselfÚoptionsÚtokenr   ÚstartÚendr	   r	   r
   r   '   s$    zPangoMarkupFormatter.__init__c           	      C   sª   d}d }|  d¡ |D ]`\}}|| jkr0|j}q||krF|t|ƒ7 }q|rj| j| \}}|  || | ¡ t|ƒ}|}q|rœ| j| \}}|  || | ¡ |  d¡ d S )Nr   z<tt>z</tt>)Úwriter   Úparentr   )	r   ZtokensourceÚoutfileZlastvalZlasttypeÚttypeÚvalueZ
stylebeginZstyleendr	   r	   r
   Úformat_unencoded=   s"    

z%PangoMarkupFormatter.format_unencodedN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚaliasesÚ	filenamesr   r   r	   r	   r	   r
   r      s   N)r   Zpygments.formatterr   Ú__all__ÚordZ_escape_tabler   r   r	   r	   r	   r
   Ú<module>   s   
  þ