§
    )P„jì6  ã                  ó  — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZ e
r	dd	lmc mZ 	 dd
lmZ ddlmZmZ ddlmZ ddlmZ dZn# e$ r dZY nw xY wdd„Z G d„ d¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Zd„ Zd	S )z¨
Adds code/syntax highlighting to standard Python-Markdown code blocks.

See the [documentation](https://Python-Markdown.github.io/extensions/code_hilite)
for details.
é    )Úannotationsé   )Ú	Extensioné   )ÚTreeprocessor)ÚparseBoolValue)ÚTYPE_CHECKINGÚCallableÚAnyN)Ú	highlight)Úget_lexer_by_nameÚguess_lexer)Úget_formatter_by_name)ÚClassNotFoundTFÚexprÚstrÚreturnú	list[int]c                ó˜   — | sg S 	 t          t          t          |                      ¦   «         ¦  «        ¦  «        S # t          $ r g cY S w xY w)zÊSupport our syntax for emphasizing certain lines of code.

    `expr` should be like '1 2' to emphasize lines 1 and 2 of a code block.
    Returns a list of integers, the line numbers to emphasize.
    )ÚlistÚmapÚintÚsplitÚ
ValueError)r   s    úc/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/markdown/extensions/codehilite.pyÚparse_hl_linesr   *   sZ   € ð ð Øˆ	ðÝ•C�˜TŸZšZ™\œ\Ñ*Ô*Ñ+Ô+Ð+øÝð ð ð Øˆ	ˆ	ˆ	ðøøøs   †3: ºA	ÁA	c                  ó,   — e Zd ZdZdd„Zddd	„Zdd„ZdS )Ú
CodeHiliteau	  
    Determine language of source code, and pass it on to the Pygments highlighter.

    Usage:

    ```python
    code = CodeHilite(src=some_code, lang='python')
    html = code.hilite()
    ```

    Arguments:
        src: Source string or any object with a `.readline` attribute.

    Keyword arguments:
        lang (str): String name of Pygments lexer to use for highlighting. Default: `None`.
        guess_lang (bool): Auto-detect which lexer to use.
            Ignored if `lang` is set to a valid value. Default: `True`.
        use_pygments (bool): Pass code to Pygments for code highlighting. If `False`, the code is
            instead wrapped for highlighting by a JavaScript library. Default: `True`.
        pygments_formatter (str): The name of a Pygments formatter or a formatter class used for
            highlighting the code blocks. Default: `html`.
        linenums (bool): An alias to Pygments `linenos` formatter option. Default: `None`.
        css_class (str): An alias to Pygments `cssclass` formatter option. Default: 'codehilite'.
        lang_prefix (str): Prefix prepended to the language. Default: "language-".

    Other Options:

    Any other options are accepted and passed on to the lexer and formatter. Therefore,
    valid options include any options which are accepted by the `html` formatter or
    whichever lexer the code's language uses. Note that most lexers do not have any
    options. However, a few have very useful options, such as PHP's `startinline` option.
    Any invalid options are ignored without error.

    * **Formatter options**: <https://pygments.org/docs/formatters/#HtmlFormatter>
    * **Lexer Options**: <https://pygments.org/docs/lexers/>

    Additionally, when Pygments is enabled, the code's language is passed to the
    formatter as an extra option `lang_str`, whose value being `{lang_prefix}{lang}`.
    This option has no effect to the Pygments' builtin formatters.

    Advanced Usage:

    ```python
    code = CodeHilite(
        src = some_code,
        lang = 'php',
        startinline = True,      # Lexer option. Snippet does not start with `<?php`.
        linenostart = 42,        # Formatter option. Snippet starts on line 42.
        hl_lines = [45, 49, 50], # Formatter option. Highlight lines 45, 49, and 50.
        linenos = 'inline'       # Formatter option. Avoid alignment problems.
    )
    html = code.hilite()
    ```

    Úsrcr   c                óÀ  — || _         |                     dd ¦  «        | _        |                     dd¦  «        | _        |                     dd¦  «        | _        |                     dd¦  «        | _        |                     dd¦  «        | _        d	|vr|                     d
d ¦  «        |d	<   d|vr|                     dd¦  «        |d<   d|vrd|d<   d|d<   || _        d S )NÚlangÚ
guess_langTÚuse_pygmentsÚlang_prefixú	language-Úpygments_formatterÚhtmlÚlinenosÚlinenumsÚcssclassÚ	css_classÚ
codehiliteÚwrapcodeFÚfull)r   Úpopr!   r"   r#   r$   r&   Úoptions)Úselfr   r0   s      r   Ú__init__zCodeHilite.__init__s   sæ   € ØˆŒØ '§¢¨F°DÑ 9Ô 9ˆŒ	Ø '§¢¨L¸$Ñ ?Ô ?ˆŒØ")§+¢+¨n¸dÑ"CÔ"CˆÔØ '§¢¨M¸;Ñ GÔ GˆÔØ29·+²+Ð>RÐTZÑ2[Ô2[ˆÔà˜GÐ#Ð#Ø!(§¢¨Z¸Ñ!>Ô!>ˆG�IÑØ˜WÐ$Ð$Ø")§+¢+¨k¸<Ñ"HÔ"HˆG�JÑØ˜WÐ$Ð$à"&ˆG�JÑàˆ�‰àˆŒˆˆó    TÚshebangÚboolr   c                óò  — | j                              d¦  «        | _         | j        €|r|                      ¦   «          t          �r+| j        �r#	 t          | j        fi | j        ¤Ž}nc# t          $ rV 	 | j	        rt          | j         fi | j        ¤Ž}nt          di | j        ¤Ž}n!# t          $ r t          di | j        ¤Ž}Y nw xY wY nw xY w| j        s|j        d         | _        | j        › | j        › �}t          | j        t          ¦  «        r:	 t!          | j        fi | j        ¤Ž}n5# t"          $ r t!          di | j        ¤Ž}Y nw xY w | j        dd|i| j        ¤Ž}t%          | j         ||¦  «        S | j                              dd¦  «        }|                     d	d
¦  «        }|                     dd¦  «        }|                     dd¦  «        }g }| j        r3|                     d                     | j        | j        ¦  «        ¦  «         | j        d         r|                     d¦  «         d}|r(d                     d                     |¦  «        ¦  «        }d                     | j        d         ||¦  «        S )a6  
        Pass code to the [Pygments](https://pygments.org/) highlighter with
        optional line numbers. The output should then be styled with CSS to
        your liking. No styles are applied by default - only styling hooks
        (i.e.: `<span class="k">`).

        returns : A string of html.

        ú
NÚtextr   r'   Úlang_strú&ú&amp;ú<ú&lt;ú>ú&gt;ú"z&quot;z{}{}r(   r)   Ú z class="{}"ú z)<pre class="{}"><code{}>{}
</code></pre>
r*   )r8   )r'   © )r   Ústripr!   Ú_parseHeaderÚpygmentsr#   r   r0   r   r"   r   Úaliasesr$   Ú
isinstancer&   r   r   r   r   ÚreplaceÚappendÚformatÚjoin)r1   r4   Úlexerr9   Ú	formatterÚtxtÚclassesÚ	class_strs           r   ÚhilitezCodeHilite.hilite‡   sÙ  € ð ”8—>’> $Ñ'Ô'ˆŒàŒ9Ð ÐØ×ÒÑÔÐåñ )	˜Ô)ñ )	ð	FÝ)¨$¬)ÐDÐD°t´|ÐDÐD��øÝð Fð Fð FðFØ”ð JÝ +¨D¬HÐ EÐ E¸¼Ð EÐ E˜˜å 1Ð IÐ I¸D¼LÐ IÐ I˜øøÝ!ð Fð Fð FÝ-ÐEÐE¸¼ÐEÐE�E�E�EðFøøøøøðFøøøð ”9ð -à!œM¨!Ô,�”	ØÔ*Ð7¨D¬IÐ7Ð7ˆHÝ˜$Ô1µ3Ñ7Ô7ð WðNÝ 5°dÔ6MÐ ^Ð ^ÐQUÔQ]Ð ^Ð ^�I�IøÝ$ð Nð Nð NÝ 5Ð MÐ MÀÄÐ MÐ M�I�I�IðNøøøð 4˜DÔ3ÐVÐV¸XÐVÈÌÐVÐV�	Ý˜TœX u¨iÑ8Ô8Ð8ð ”(×"Ò" 3¨Ñ0Ô0ˆCØ—+’+˜c 6Ñ*Ô*ˆCØ—+’+˜c 6Ñ*Ô*ˆCØ—+’+˜c 8Ñ,Ô,ˆCØˆGØŒyð KØ—’˜vŸ}š}¨TÔ-=¸t¼yÑIÔIÑJÔJÐJØŒ|˜IÔ&ð +Ø—’˜zÑ*Ô*Ð*ØˆIØð DØ)×0Ò0°·²¸'Ñ1BÔ1BÑCÔC�	Ø@×GÒGØ”˜ZÔ(ØØñô ð sH   ÁA& Á&
CÁ10B"Â!CÂ"C Â=CÂ?C Ã CÃCÄD% Ä%EÅEÚNonec                óä  — ddl }| j                             d¦  «        }|                     d¦  «        }|                     d|j        ¦  «        }|                     |¦  «        }|rÇ	 |                     d¦  «                             ¦   «         | _	        n# t          $ r
 d| _	        Y nw xY w|                     d¦  «        r|                     d|¦  «         | j        d         €|                     d¦  «        r
d	| j        d<   t          |                     d
¦  «        ¦  «        | j        d
<   n|                     d|¦  «         d                     |¦  «                             d¦  «        | _        dS )aP  
        Determines language of a code block from shebang line and whether the
        said line should be removed or left in place. If the shebang line
        contains a path (even a single /) then it is assumed to be a real
        shebang line and left alone. However, if no path is given
        (e.i.: `#!python` or `:::python`) then it is assumed to be a mock shebang
        for language identification of a code fragment and removed from the
        code block prior to processing for code highlighting. When a mock
        shebang (e.i: `#!python`) is found, line numbering is turned on. When
        colons are found in place of a shebang (e.i.: `:::python`), line
        numbering is left in the current state - off by default.

        Also parses optional list of highlight lines, like:

            :::python hl_lines="1 3"
        r   Nr7   aœ  
            (?:(?:^::+)|(?P<shebang>^[#]!)) # Shebang or 2 or more colons
            (?P<path>(?:/\w+)*[/ ])?        # Zero or 1 path
            (?P<lang>[\w#.+-]*)             # The language
            \s*                             # Arbitrary whitespace
            # Optional highlight lines, single- or double-quote-delimited
            (hl_lines=(?P<quot>"|')(?P<hl_lines>.*?)(?P=quot))?
            r!   Úpathr(   r4   TÚhl_lines)Úrer   r   r/   ÚcompileÚVERBOSEÚsearchÚgroupÚlowerr!   Ú
IndexErrorÚinsertr0   r   rL   rD   )r1   rW   ÚlinesÚflÚcÚms         r   rE   zCodeHilite._parseHeaderÂ   sa  € ð$ 	ˆ	ˆ	ˆ	ð ”—’˜tÑ$Ô$ˆà�YŠY�q‰\Œ\ˆà�JŠJð ð ”*ñô ˆð �HŠH�R‰LŒLˆØð 	 ð!ØŸGšG F™OœO×1Ò1Ñ3Ô3�”	�	øÝð !ð !ð !Ø �”	�	�	ð!øøøà�wŠw�v‰Œð $à—’˜Q Ñ#Ô#Ð#ØŒ|˜IÔ&Ð.°1·7²7¸9Ñ3EÔ3EÐ.à*.�”˜YÑ'å'5°a·g²g¸jÑ6IÔ6IÑ'JÔ'JˆDŒL˜Ñ$Ð$ð �LŠL˜˜BÑÔÐà—9’9˜UÑ#Ô#×)Ò)¨$Ñ/Ô/ˆŒˆˆs   Á',B ÂB(Â'B(N)r   r   )T)r4   r5   r   r   )r   rS   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r2   rR   rE   rC   r3   r   r   r   :   sa   € € € € € ð6ð 6ðpð ð ð ð(9ð 9ð 9ð 9ð 9ðv50ð 50ð 50ð 50ð 50ð 50r3   r   c                  ó.   — e Zd ZU dZded<   dd„Zdd„ZdS )ÚHiliteTreeprocessorz' Highlight source code in code blocks. zdict[str, Any]Úconfigr8   r   r   c                óŠ   — |                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|S )zUnescape code.r=   r<   r?   r>   r;   r:   )rI   )r1   r8   s     r   Úcode_unescapez!HiliteTreeprocessor.code_unescape  sB   € à�|Š|˜F CÑ(Ô(ˆØ�|Š|˜F CÑ(Ô(ˆð �|Š|˜G SÑ)Ô)ˆØˆr3   Úrootúetree.ElementrS   c           	     óü  — |                      d¦  «        }|D ]ã}t          |¦  «        dk    rÎ|d         j        dk    r½| j                             ¦   «         }|d         j        }|€ŒOt          |                      |¦  «        f| j        j	        | 
                    dd¦  «        dœ|¤Ž}| j        j                             |                     ¦   «         ¦  «        }|                     ¦   «          d	|_        ||_        ŒädS )
z, Find code blocks and store in `htmlStash`. Úprer   r   ÚcodeNÚpygments_styleÚdefault)Ú
tab_lengthÚstyleÚp)ÚiterÚlenÚtagri   Úcopyr8   r   rk   Úmdrs   r/   Ú	htmlStashÚstorerR   Úclear)r1   rl   ÚblocksÚblockÚlocal_configr8   rp   Úplaceholders           r   ÚrunzHiliteTreeprocessor.run  s  € à—’˜5Ñ!Ô!ˆØð 	)ð 	)ˆEÝ�5‰zŒz˜QŠˆ 5¨¤8¤<°6Ò#9Ð#9Ø#œ{×/Ò/Ñ1Ô1�Ø˜Q”x”}�Ø�<ØÝ!Ø×&Ò& tÑ,Ô,ðà#œwÔ1Ø&×*Ò*Ð+;¸YÑGÔGðð ð #ð	ð �ð #œgÔ/×5Ò5°d·k²k±m´mÑDÔD�à—’‘”�ð  �”	Ø(�”
øð%	)ð 	)r3   N)r8   r   r   r   )rl   rm   r   rS   )rc   rd   re   rf   Ú__annotations__rk   r‚   rC   r3   r   rh   rh   ý   sP   € € € € € € Ø1Ð1àÐÐÑðð ð ð ð)ð )ð )ð )ð )ð )r3   rh   c                  ó   — e Zd ZdZd„ Zd„ ZdS )ÚCodeHiliteExtensionz7 Add source code highlighting to markdown code blocks. c           	     óD  — d dgddgddgddgdd	gdd
gddgddgdœ| _         	 |                     ¦   «         D ]i\  }}|| j         v r|                      ||¦  «         Œ%t          |t          ¦  «        r#	 t          |d¬¦  «        }n# t          $ r Y nw xY w|dg| j         |<   Œjd S )NzOUse lines numbers. True|table|inline=yes, False=no, None=auto. Default: `None`.Tz/Automatic language detection - Default: `True`.r,   z9Set class name for wrapper <div> - Default: `codehilite`.rr   z@Pygments HTML Formatter Style (Colorscheme). Default: `default`.Fz;Use inline styles instead of CSS classes - Default `False`.z\Highlight code blocks with pygments. Disable if using a JavaScript library. Default: `True`.r%   zTPrefix prepended to the language when `use_pygments` is false. Default: `language-`.r'   zDUse a specific formatter for Pygments highlighting. Default: `html`.)r)   r"   r+   rq   Ú	noclassesr#   r$   r&   )Úpreserve_nonerA   )ri   ÚitemsÚ	setConfigrH   r   r   r   )r1   ÚkwargsÚkeyÚvalues       r   r2   zCodeHiliteExtension.__init__&  s&  € ð Ðgðð ÐGðð ÐYðð Ð]ðð ÐTðð Ðtðð Ðsðð Ð^ð#ð-
ð 
ˆŒð4 	/à Ÿ,š,™.œ.ð 	/ð 	/‰JˆC�Ø�d”kÐ!Ð!Ø—’˜s EÑ*Ô*Ð*Ð*õ ˜e¥SÑ)Ô)ð ðå .¨uÀDÐ IÑ IÔ I˜˜øÝ%ð ð ð Ø˜ðøøøà$)¨2 ;�”˜CÑ Ð ð	/ð 	/s   Á1BÂ
BÂBc                ó¸   — t          |¦  «        }|                      ¦   «         |_        |j                             |dd¦  «         |                     | ¦  «         dS )a6  
        Register the processor.

        | Class Instance                                                              | Registry                                                         | Name   | Priority |
        | --------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------ | :------: |
        | [`HiliteTreeprocessor`][markdown.extensions.codehilite.HiliteTreeprocessor] | [`treeprocessors`][markdown.treeprocessors.build_treeprocessors] | `hilite` | `30` |

        rR   é   N)rh   Ú
getConfigsri   ÚtreeprocessorsÚregisterÚregisterExtension)r1   rz   Úhiliters      r   ÚextendMarkdownz"CodeHiliteExtension.extendMarkdownQ  sW   € õ & bÑ)Ô)ˆØŸšÑ*Ô*ˆŒØ
Ô×"Ò" 7¨H°bÑ9Ô9Ð9à
×Ò˜TÑ"Ô"Ð"Ð"Ð"r3   N)rc   rd   re   rf   r2   r•   rC   r3   r   r…   r…   #  s9   € € € € € ØAÐAð)/ð )/ð )/ðV#ð #ð #ð #ð #r3   r…   c                 ó   — t          di | ¤ŽS )NrC   )r…   )r‹   s    r   ÚmakeExtensionr—   b  s   € ÝÐ(Ð( Ð(Ð(Ð(r3   )r   r   r   r   )rf   Ú
__future__r   rA   r   r‘   r   Úutilr   Útypingr	   r
   r   Úxml.etree.ElementTreeÚetreeÚElementTreerF   r   Úpygments.lexersr   r   Úpygments.formattersr   Úpygments.utilr   ÚImportErrorr   r   rh   r…   r—   rC   r3   r   ú<module>r¢      sÌ  ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø *Ð *Ð *Ð *Ð *Ð *Ø !Ð !Ð !Ð !Ð !Ð !Ø /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /àð *Ø)Ð)Ð)Ð)Ð)Ð)Ð)Ð)Ð)ðØ"Ð"Ð"Ð"Ð"Ð"Ø>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Ø9Ð9Ð9Ð9Ð9Ð9Ø+Ð+Ð+Ð+Ð+Ð+Ø€H€HøØð ð ð Ø€H€H€Hðøøøðð ð ð ð }0ð }0ð }0ð }0ð }0ñ }0ô }0ð }0ðF#)ð #)ð #)ð #)ð #)˜-ñ #)ô #)ð #)ðL<#ð <#ð <#ð <#ð <#˜)ñ <#ô <#ð <#ð~)ð )ð )ð )ð )s   ±A ÁAÁA