+
    Z‹iÂ4  ã                  ó  € R t ^ RIHt ^RIHt ^RIHt ^RIHt ^ RI	H
t
HtHt ]
'       d
   ^ RIHu Ht  ^ RIHt ^ RIHtHt ^ R	IHt ^ R
IHt RtR R lt ! R R4      t ! R R]4      t ! R R]4      tR tR#   ] d    Rt L6i ; i)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)ÚClassNotFoundTFc               ó    € V ^8„  d   QhRRRR/# )é   ÚexprÚstrÚreturnz	list[int]© )Úformats   "Ú@/usr/lib/python3/dist-packages/markdown/extensions/codehilite.pyÚ__annotate__r   *   s   € ÷ ñ ˜ð  ñ ó    c                óŒ   € V '       g   . #  \        \        \        V P                  4       4      4      #   \         d    . u # i ; i)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   &r   Úparse_hl_linesr   *   s=   € ÷ Øˆ	ðÜ”Cœ˜TŸZ™Z›\Ó*Ó+Ð+øÜô ØŠ	ðús   Œ&3 ³AÁAc                  óB   € ] tR t^:tRtR R ltR
R R lltR R ltRtR	# )Ú
CodeHiliteaÉ  
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()
```

c               ó   € V ^8„  d   QhRR/# )r   Úsrcr   r   )r   s   "r   r   ÚCodeHilite.__annotate__s   s   € ÷ ñ ˜Cñ r   c                	ó–  € Wn         VP                  R R4      V n        VP                  RR4      V n        VP                  RR4      V n        VP                  RR4      V n        VP                  RR4      V n        R	V9  d   VP                  R
R4      VR	&   RV9  d   VP                  RR4      VR&   RV9  d   RVR&   RVR&   W n        R# )ÚlangNÚ
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"   r4   s   &&,r   Ú__init__ÚCodeHilite.__init__s   sÀ   € ØŒØ '§¡¨F°DÓ 9ˆŒ	Ø '§¡¨L¸$Ó ?ˆŒØ")§+¡+¨n¸dÓ"CˆÔØ '§¡¨M¸;Ó GˆÔØ29·+±+Ð>RÐTZÓ2[ˆÔà˜GÔ#Ø!(§¡¨Z¸Ó!>ˆG�IÑØ˜WÔ$Ø")§+¡+¨k¸<Ó"HˆG�JÑØ˜WÔ$à"&ˆG�JÑàˆ�‰àŽr   c               ó    € V ^8„  d   QhRRRR/# )r   ÚshebangÚboolr   r   r   )r   s   "r   r   r#   ‡   s   € ÷ 9ñ 9˜dð 9¨cñ 9r   c                óþ  € V P                   P                  R4      V n         V P                  f   V'       d   V P                  4        \        '       dî   V P
                  '       dÜ    \        V P                  3/ V P                  B pT P                  '       g   TP                  ^ ,          T n        T P                   T P                   2p\        T P                  \        4      '       d#    \!        T P                  3/ T P                  B pMT P                  ! RRT/T P                  B p\%        T P                   Y$4      # V P                   P'                  RR4      pVP'                  RR4      pVP'                  RR4      pVP'                  R	R
4      p. pV P                  '       d6   VP)                  RP+                  V P                  V P                  4      4       V P                  R,          '       d   VP)                  R4       RpV'       d!   RP+                  RP-                  V4      4      pRP+                  V P                  R,          VV4      #   \         dx     T P                  '       d$   \        T P                   3/ T P                  B p EL\        R/ T P                  B p EL&  \         d    \        R/ T P                  B p  ELJi ; ii ; i  \"         d    \!        R/ T P                  B p ELÑi ; i)a  
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.

Ú
Úlang_strÚ&ú&amp;Ú<ú&lt;Ú>ú&gt;Ú"z&quot;z{}{}r,   r-   Ú z class="{}"Ú z)<pre class="{}"><code{}>{}
</code></pre>
r.   )Útext)r+   r   )r"   Ústripr%   Ú_parseHeaderÚpygmentsr'   r
   r4   r   r&   r   Úaliasesr(   Ú
isinstancer*   r   r   r   r	   ÚreplaceÚappendr   Újoin)r5   r9   Úlexerr=   Ú	formatterÚtxtÚclassesÚ	class_strs   &&      r   ÚhiliteÚCodeHilite.hilite‡   s]  € ð —8‘8—>‘> $Ó'ˆŒà�9‰9Ò§Ø×ÑÔç‹8˜×)×)Ð)ð	FÜ)¨$¯)©)ÑD°t·|±|ÑD�ð —9—9�9à!ŸM™M¨!Õ,�”	Ø×*Ñ*Ð+¨D¯I©I¨;Ð7ˆHÜ˜$×1Ñ1´3×7Ò7ðNÜ 5°d×6MÑ6MÑ ^ÐQU×Q]ÑQ]Ñ ^‘Ið !×3Ò3ÑV¸XÐVÈÏÉÑV�	Ü˜TŸX™X uÓ8Ð8ð —(‘(×"Ñ" 3¨Ó0ˆCØ—+‘+˜c 6Ó*ˆCØ—+‘+˜c 6Ó*ˆCØ—+‘+˜c 8Ó,ˆCØˆGØ�y�yˆyØ—‘˜vŸ}™}¨T×-=Ñ-=¸t¿y¹yÓIÔJØ�|‰|˜I×&Ô&Ø—‘˜zÔ*ØˆIßØ)×0Ñ0°·±¸'Ó1BÓC�	Ø@×GÑGØ—‘˜ZÕ(ØØóð øôE ô FðFØ——�Ü +¨D¯H©HÑ E¸¿¹Ñ E›ä 1Ñ I¸D¿L¹LÑ I›øÜ!ô FÜ-ÑE¸¿¹ÑE”EðFúðFûô %ô NÜ 5Ñ MÀÇÁÑ M“IðNúsH   Á& I Ã+ K ÉKÉJ,É1 J,ÊJ,Ê, KËKËKËKË K<Ë;K<c               ó   € V ^8„  d   QhRR/# )r   r   ÚNoner   )r   s   "r   r   r#   Â   s   € ÷ 50ñ 50˜dñ 50r   c                óÐ  € ^ RI pV P                  P                  R4      pVP                  ^ 4      pVP	                  RVP
                  4      pVP                  V4      pV'       d²    VP                  R4      P                  4       V n	        VP                  R4      '       d   VP                  ^ V4       V P                  R,          f'   VP                  R4      '       d   RV P                  R&   \        VP                  R	4      4      V P                  R	&   MVP                  ^ V4       RP                  V4      P                  R4      V n        R#   \         d    RT n	         LÙi ; i)
aè  
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"
Nr<   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,   r9   TÚhl_lines)Úrer"   r   r3   ÚcompileÚVERBOSEÚsearchÚgroupÚlowerr%   Ú
IndexErrorÚinsertr4   r   rO   rH   )r5   r\   ÚlinesÚflÚcÚms   &     r   rI   ÚCodeHilite._parseHeaderÂ   s  € ó$ 	ð —‘—‘˜tÓ$ˆà�Y‰Y�q‹\ˆà�J‰Jð ð —*‘*óˆð �H‰H�R‹Lˆßð!ØŸG™G F›O×1Ñ1Ó3�”	ð �w‰w�v�Šà—‘˜Q Ô#Ø�|‰|˜IÕ&Ò.°1·7±7¸9×3EÒ3Eà*.�—‘˜YÑ'ä'5°a·g±g¸jÓ6IÓ'JˆD�L‰L˜Ò$ð �L‰L˜˜BÔà—9‘9˜UÓ#×)Ñ)¨$Ó/ˆŽøô ô !Ø �–	ð!ús   Á'$E ÅE%Å$E%)r&   r%   r(   r4   r*   r"   r'   N)T)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r6   rU   rI   Ú__static_attributes__r   r   r   r    r    :   s   † ñ6õp÷(9÷v50ñ 50r   r    c                  ó>   € ] tR t^ýt$ RtR]R&   R R ltR R ltRtR	# )
ÚHiliteTreeprocessorz&Highlight source code in code blocks. zdict[str, Any]Úconfigc               ó    € V ^8„  d   QhRRRR/# )r   rG   r   r   r   )r   s   "r   r   Ú HiliteTreeprocessor.__annotate__  s   € ÷ ñ  #ð ¨#ñ r   c                ór   € VP                  RR4      pVP                  RR4      pVP                  RR4      pV# )zUnescape code.rA   r@   rC   rB   r?   r>   )rM   )r5   rG   s   &&r   Úcode_unescapeÚ!HiliteTreeprocessor.code_unescape  s9   € à�|‰|˜F CÓ(ˆØ�|‰|˜F CÓ(ˆð �|‰|˜G SÓ)ˆØˆr   c               ó    € V ^8„  d   QhRRRR/# )r   Úrootzetree.Elementr   rX   r   )r   s   "r   r   rs     s   € ÷ )ñ )˜ð )¨$ñ )r   c                ó  € VP                  R4      pV Fõ  p\        V4      ^8X  g   K  V^ ,          P                  R8X  g   K/  V P                  P	                  4       pV^ ,          P
                  pVf   Kb  \        V P                  V4      3RV P                  P                  RVP                  RR4      /VB pV P                  P                  P                  VP                  4       4      pVP                  4        RVn        Wsn        K÷  	  R# )	z+Find code blocks and store in `htmlStash`. ÚpreÚcodeNÚ
tab_lengthÚstyleÚpygments_styleÚdefaultÚp)ÚiterÚlenÚtagrq   ÚcopyrG   r    ru   Úmdr|   r3   Ú	htmlStashÚstorerU   Úclear)r5   rx   ÚblocksÚblockÚlocal_configrG   r{   Úplaceholders   &&      r   ÚrunÚHiliteTreeprocessor.run  sà   € à—‘˜5Ó!ˆÛˆEÜ�5‹z˜QŽ 5¨¥8§<¡<°6Ö#9Ø#Ÿ{™{×/Ñ/Ó1�Ø˜Q•x—}‘}�Ø’<ÙÜ!Ø×&Ñ& tÓ,ñà#Ÿw™w×1Ñ1ðð '×*Ñ*Ð+;¸YÓGðð #ñ	�ð #Ÿg™g×/Ñ/×5Ñ5°d·k±k³mÓD�à—‘”ð  �”	Ø(–
ó% r   r   N)	ri   rj   rk   rl   rm   Ú__annotations__ru   r�   rn   r   r   r   rp   rp   ý   s   ‡ Ù1àÓõ÷)ñ )r   rp   c                  ó&   € ] tR tRtRtR tR tRtR# )ÚCodeHiliteExtensioni#  z6Add source code highlighting to markdown code blocks. c                	óZ  € R RR.RRR.RRR.R	R
R.RRR.RRR.RRR.RRR./V n          VP                  4        F]  w  r#W P                   9   d   V P                  W#4       K(  \        V\        4      '       d    \        VRR7      pVR.V P                   V&   K_  	  R#   \         d     L$i ; i)r-   NzOUse lines numbers. True|table|inline=yes, False=no, None=auto. Default: `None`.r&   Tz/Automatic language detection - Default: `True`.r/   r0   z9Set class name for wrapper <div> - Default: `codehilite`.r~   r   z@Pygments HTML Formatter Style (Colorscheme). Default: `default`.Ú	noclassesFz;Use inline styles instead of CSS classes - Default `False`.r'   z\Highlight code blocks with pygments. Disable if using a JavaScript library. Default: `True`.r(   r)   zTPrefix prepended to the language when `use_pygments` is false. Default: `language-`.r*   r+   zDUse a specific formatter for Pygments highlighting. Default: `html`.)Úpreserve_nonerE   )rq   ÚitemsÚ	setConfigrL   r   r   r   )r5   ÚkwargsÚkeyÚvalues   &,  r   r6   ÚCodeHiliteExtension.__init__&  s   € ð ØÐgðð ØÐGðð ØÐYðð ØÐ]ðð ØÐTðð ØÐtðð ØÐsðð !ØÐ^ð#ð-
ˆŒð4 	/à Ÿ,™,ž.‰JˆCØ—k‘kÔ!Ø—‘˜sÖ*ô ˜e¤S×)Ò)ðä .¨uÀDÔ I˜ð %*¨2 ;�—‘˜CÓ ó )øô &ô Ùðús   Á8BÂB*Â)B*c                ó¢   € \        V4      pV P                  4       Vn        VP                  P	                  VR^4       VP                  V 4       R# )z0Add `HilitePostprocessor` to Markdown instance. rU   N)rp   Ú
getConfigsrq   ÚtreeprocessorsÚregisterÚregisterExtension)r5   r…   Úhiliters   && r   ÚextendMarkdownÚ"CodeHiliteExtension.extendMarkdownQ  s@   € ä% bÓ)ˆØŸ™Ó*ˆŒØ
×Ñ×"Ñ" 7¨H°bÔ9à
×Ñ˜TÖ"r   )rq   N)ri   rj   rk   rl   rm   r6   r¡   rn   r   r   r   r‘   r‘   #  s   † ÙAò)/öV#r   r‘   c                 ó   € \        R/ V B # )Nr   )r‘   )r—   s   ,r   ÚmakeExtensionr¤   Z  s   € ÜÑ( Ñ(Ð(r   )rm   Ú
__future__r   rE   r   r�   r   Úutilr   Útypingr   r   r   Úxml.etree.ElementTreeÚetreeÚElementTreerJ   r	   Úpygments.lexersr
   r   Úpygments.formattersr   Úpygments.utilr   ÚImportErrorr   r    rp   r‘   r¤   r   r   r   Ú<module>r¯      s…   ðñõ #å Ý *Ý !ß /Ñ /çß)Ð)ðÝ"ß>Ý9Ý+Ø€Hõ
÷ }0ñ }0ôF#)˜-ô #)ôL4#˜)ô 4#ôn)øði	 ô Ø‚Hðús   ·A> Á>	B
Â	B
