§
    )P„j_0  ã            
      ól  — d Z ddl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d	lmZmZ erdd
lmZ ddlmZ ddlZddlmc mZ dZdZdZdZddddddddddœ	Zdez  Zdez  ZdZdZdez  Zd ez  Zd!Z d"ez  Z!d#Z"d$ez  Z#d%ez  Z$d&ez  Z%d'Z&d(Z'd)Z(ed*z   Z) G d+„ d,e¦  «        Z* G d-„ d.e¦  «        Z+d/„ Z,dS )0z¨
Convert ASCII dashes, quotes and ellipses to their HTML entity equivalents.

See the [documentation](https://Python-Markdown.github.io/extensions/smarty)
for details.
é    )Úannotationsé   )Ú	Extensioné   )ÚHtmlInlineProcessorÚHTML_RE)ÚInlineProcessor)ÚRegistry)ÚTYPE_CHECKINGÚSequence)ÚMarkdown)ÚinlinepatternsNz)[!"#\$\%'()*+,-.\/:;<=>?\@\[\\\]\^_`{|}~]z[\s.,;:!?)]z[^\ \t\r\n\[\{\(\-\u0002\u0003]u1   (\s|&nbsp;|--|â€“|â€”|&[mn]dash;|&#8211;|&#8212;)z&mdash;z&ndash;z&hellip;z&laquo;z&raquo;z&lsquo;z&rsquo;z&ldquo;z&rdquo;)	ÚmdashÚndashÚellipsisúleft-angle-quoteúright-angle-quoteúleft-single-quoteúright-single-quoteúleft-double-quoteúright-double-quotez
^'(?=%s\B)z
^"(?=%s\B)z"'(?=\w)z'"(?=\w)z
(?<=%s)\'"z
(?<=%s)\"'z(?<!\w)'(?=\d{2}s)z	%s"(?=\w)z"(?=\s)z(?<=%s)"z	%s'(?=\w)z(?<=%s)'(?!\s|s\b|\d)z	'(\s|s\b)ú'ú"z(?!\>)c                  ó   — e Zd Zdd„Zdd„ZdS )ÚSubstituteTextPatternÚpatternÚstrÚreplaceú#Sequence[int | str | etree.Element]Úmdr   c                óL   — t          j        | |¦  «         || _        || _        dS )z" Replaces matches with some text. N)r   Ú__init__r   r    )Úselfr   r   r    s       ú_/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/markdown/extensions/smarty.pyr"   zSubstituteTextPattern.__init__¥   s'   € åÔ$ T¨7Ñ3Ô3Ð3ØˆŒØˆŒˆˆó    Úmúre.Match[str]ÚdataÚreturnútuple[str, int, int]c                ó  — d}| j         D ]R}t          |t          ¦  «        r||                     |¦  «        z  }Œ0|| j        j                             |¦  «        z  }ŒS||                     d¦  «        |                     d¦  «        fS )NÚ r   )	r   Ú
isinstanceÚintÚgroupr    Ú	htmlStashÚstoreÚstartÚend)r#   r&   r(   ÚresultÚparts        r$   ÚhandleMatchz!SubstituteTextPattern.handleMatch«   s€   € ØˆØ”Lð 	8ð 	8ˆDÝ˜$¥Ñ$Ô$ð 8Ø˜!Ÿ'š' $™-œ-Ñ'��à˜$œ'Ô+×1Ò1°$Ñ7Ô7Ñ7��Ø�q—w’w˜q‘z”z 1§5¢5¨¡8¤8Ð+Ð+r%   N)r   r   r   r   r    r   )r&   r'   r(   r   r)   r*   )Ú__name__Ú
__module__Ú__qualname__r"   r6   © r%   r$   r   r   ¤   s<   € € € € € ðð ð ð ð,ð ,ð ,ð ,ð ,ð ,r%   r   c                  óP   ‡ — e Zd ZdZˆ fd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	d„ Z
ˆ xZS )ÚSmartyExtensionz Add Smarty to Markdown. c                óú   •— ddgddgddgddgi dgdœ| _         	  t          ¦   «         j        di |¤Ž t          t          ¦  «        | _        | j                             |                      d	i ¬
¦  «        ¦  «         d S )NTzEducate quotesFzEducate angled quoteszEducate dasheszEducate ellipseszOverwrite default substitutions)Úsmart_quotesÚsmart_angled_quotesÚsmart_dashesÚsmart_ellipsesÚsubstitutionsrB   )Údefaultr:   )ÚconfigÚsuperr"   ÚdictrB   ÚupdateÚ	getConfig)r#   ÚkwargsÚ	__class__s     €r$   r"   zSmartyExtension.__init__·   s�   ø€ à!Ð#3Ð4Ø$)Ð+BÐ#CØ!Ð#3Ð4Ø#Ð%7Ð8Ø Ð"CÐDð
ð 
ˆŒð 	/Ø�‰ŒÔÐ"Ð"˜6Ð"Ð"Ð"Ý-1µ-Ñ-@Ô-@ˆÔØÔ×!Ò! $§.¢.°È" .Ñ"MÔ"MÑNÔNÐNÐNÐNr%   r    r   Úpatternsú9Sequence[tuple[str, Sequence[int | str | etree.Element]]]Úserier   Úpriorityr.   c                óš   — t          |¦  «        D ]:\  }}||fz  }t          |Ž }d||fz  }| j                             ||||z
  ¦  «         Œ;d S )Nzsmarty-%s-%d)Ú	enumerater   ÚinlinePatternsÚregister)r#   r    rK   rM   rN   Úindr   Únames           r$   Ú_addPatternszSmartyExtension._addPatternsÄ   ss   € õ & hÑ/Ô/ð 	Fð 	F‰LˆC�Ø˜�uÑˆGÝ+¨WÐ5ˆGØ! U¨C LÑ0ˆDØÔ×(Ò(¨°$¸À¹ÑEÔEÐEÐEð		Fð 	Fr%   r)   ÚNonec                óê   — t          d| j        d         f|¦  «        }t          d| j        d         f|¦  «        }| j                             |dd¦  «         | j                             |dd¦  «         d S )	Nz(?<!-)---(?!-)r   z(?<!-)--(?!-)r   zsmarty-em-dashesé2   zsmarty-en-dashesé-   ©r   rB   rQ   rR   )r#   r    ÚemDashesPatternÚenDashesPatterns       r$   ÚeducateDasheszSmartyExtension.educateDashesÑ   s†   € Ý/Ø Ô 2°7Ô ;Ð=¸rñ
ô 
ˆõ 0Ø˜tÔ1°'Ô:Ð<¸bñ
ô 
ˆð 	Ô×$Ò$ _Ð6HÈ"ÑMÔMÐMØÔ×$Ò$ _Ð6HÈ"ÑMÔMÐMÐMÐMr%   c                óx   — t          d| j        d         f|¦  «        }| j                             |dd¦  «         d S )Nz(?<!\.)\.{3}(?!\.)r   zsmarty-ellipsesé
   rZ   )r#   r    ÚellipsesPatterns      r$   ÚeducateEllipseszSmartyExtension.educateEllipsesÛ   sG   € Ý/Ø! DÔ$6°zÔ$BÐ#DÀbñ
ô 
ˆð 	Ô×$Ò$ _Ð6GÈÑLÔLÐLÐLÐLr%   c                óê   — t          d| j        d         f|¦  «        }t          d| j        d         f|¦  «        }| j                             |dd¦  «         | j                             |dd¦  «         d S )	Nz\<\<r   z\>\>r   zsmarty-left-angle-quotesé(   zsmarty-right-angle-quotesé#   rZ   )r#   r    ÚleftAngledQuotePatternÚrightAngledQuotePatterns       r$   ÚeducateAngledQuotesz#SmartyExtension.educateAngledQuotesá   sŽ   € Ý!6Ø�dÔ(Ð);Ô<Ð>Àñ"
ô "
Ðõ #8Ø�dÔ(Ð)<Ô=Ð?Àñ#
ô #
Ðð 	Ô×$Ò$Ð%;Ð=WÐY[Ñ\Ô\Ð\ØÔ×$Ò$Ð%<Ð>YÐ[]Ñ^Ô^Ð^Ð^Ð^r%   c                óÎ  — | j         d         }| j         d         }| j         d         }| j         d         }t          |fft          |fft          ||z   fft          ||z   fft
          ||z   fft          ||z   fft          |fft          d|fft          |fft          |dfft          |fft          d|fft          |fft          |fft          |fff}|                      ||dd¦  «         d S )Nr   r   r   r   r   Úquotesé   )rB   ÚsingleQuoteStartReÚdoubleQuoteStartReÚdoubleQuoteSetsReÚsingleQuoteSetsReÚdoubleQuoteSetsRe2ÚsingleQuoteSetsRe2ÚdecadeAbbrReÚopeningSingleQuotesRegexÚclosingSingleQuotesRegexÚclosingSingleQuotesRegex2ÚremainingSingleQuotesRegexÚopeningDoubleQuotesRegexÚclosingDoubleQuotesRegexÚclosingDoubleQuotesRegex2ÚremainingDoubleQuotesRegexrU   )r#   r    ÚlsquoÚrsquoÚldquoÚrdquorK   s          r$   ÚeducateQuoteszSmartyExtension.educateQuotesë   s  € ØÔ"Ð#6Ô7ˆØÔ"Ð#7Ô8ˆØÔ"Ð#6Ô7ˆØÔ"Ð#7Ô8ˆå % Ð*Ý % Ð*Ý ¨¡Ð 0Ð1Ý ¨¡Ð 0Ð1Ý %¨%¡-Ð!1Ð2Ý %¨%¡-Ð!1Ð2Ý˜E˜8Ð$Ý%¨¨5 zÐ2Ý%¨ xÐ0Ý&¨°¨
Ð3Ý'¨%¨Ð2Ý%¨¨5 zÐ2Ý%¨ xÐ0Ý&¨¨Ð1Ý'¨%¨Ð2ð
ˆð" 	×Ò˜"˜h¨°"Ñ5Ô5Ð5Ð5Ð5r%   c                ó@  — |                       ¦   «         }t          ¦   «         | _        |d         r|                      |¦  «         |d         r|                      |¦  «         |d         rD|                      |¦  «         |j                             t          t          |¦  «        dd¦  «         |d         r|  	                    |¦  «         t          |¦  «        }| j        |_        |j                             |dd¦  «         |j                             d	d
g¦  «         dS )aE   Register the processors.

        | Class Instance                                                              | Registry                                                         | Name   | Priority |
        | --------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------ | :------: |
        | [`markdown.treeprocessors.InlineProcessor`][markdown.treeprocessors.InlineProcessor] | [`treeprocessors`][markdown.treeprocessors.build_treeprocessors] | `smarty` | `6` |
        | [`markdown.inlinepatterns.HtmlInlineProcessor`][markdown.inlinepatterns.HtmlInlineProcessor] | [`inlinepatterns`][markdown.inlinepatterns.build_inlinepatterns] | `html` | `90` |

        The `HtmlInlineProcessor` , above, is only used if the `smart_angled_quotes` option is enabled.

        The `InlineProcessor`, above, is a separate instance from the `InlineProcessor` used for
        standard inline parsing. It contains a collection of inline patterns dependent upon the
        various configuration options.

        rA   r>   r?   ÚhtmléZ   r@   Úsmartyé   r   r   N)Ú
getConfigsr
   rQ   ra   r~   rg   rR   r   ÚHTML_STRICT_REr]   r	   ÚtreeprocessorsÚESCAPED_CHARSÚextend)r#   r    ÚconfigsÚinlineProcessors       r$   ÚextendMarkdownzSmartyExtension.extendMarkdown  s$  € ð  —/’/Ñ#Ô#ˆÝHPÉ
Ì
ˆÔØÐ#Ô$ð 	%Ø× Ò  Ñ$Ô$Ð$Ø�>Ô"ð 	#Ø×Ò˜rÑ"Ô"Ð"ØÐ(Ô)ð 	\Ø×$Ò$ RÑ(Ô(Ð(ð Ô×&Ò&Õ':½>È2Ñ'NÔ'NÐPVÐXZÑ[Ô[Ð[Ø�>Ô"ð 	#Ø×Ò˜rÑ"Ô"Ð"Ý)¨"Ñ-Ô-ˆØ)-Ô)<ˆÔ&Ø
Ô×"Ò" ?°H¸aÑ@Ô@Ð@Ø
Ô×Ò  c 
Ñ+Ô+Ð+Ð+Ð+r%   )r    r   rK   rL   rM   r   rN   r.   )r    r   r)   rV   )r7   r8   r9   Ú__doc__r"   rU   r]   ra   rg   r~   r‹   Ú__classcell__)rJ   s   @r$   r<   r<   µ   sÆ   ø€ € € € € Ø#Ð#ðOð Oð Oð Oð OðFð Fð Fð FðNð Nð Nð NðMð Mð Mð Mð_ð _ð _ð _ð6ð 6ð 6ð 6ð0 ,ð  ,ð  ,ð  ,ð  ,ð  ,ð  ,r%   r<   c                 ó   — t          di | ¤ŽS )Nr:   )r<   )rI   s    r$   ÚmakeExtensionr�   &  s   € ÝÐ$Ð$˜VÐ$Ð$Ð$r%   )-rŒ   Ú
__future__r   r,   r   r   r   r   r†   r	   Úutilr
   Útypingr   r   Úmarkdownr   ÚreÚxml.etree.ElementTreeÚetreeÚElementTreeÚ
punctClassÚendOfWordClassÚ
closeClassÚopeningQuotesBaserB   rk   rl   rm   rn   ro   rp   rq   rv   rw   rx   rr   rs   rt   ru   ry   r…   r   r<   r�   r:   r%   r$   ú<module>rœ      s2  ðð^ð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø Ð Ð Ð Ð Ð Ø *Ð *Ð *Ð *Ð *Ð *Ð *Ð *àð *Ø!Ð!Ð!Ð!Ð!Ð!Ø!Ð!Ð!Ð!Ð!Ð!Ø€I€I€IØ)Ð)Ð)Ð)Ð)Ð)Ð)Ð)Ð)ð >€
Ø€Ø/€
ð	ð ð ØØØ!Ø"Ø"Ø#Ø"Ø#ð
ð 
€ð # ZÑ/Ð Ø" ZÑ/Ð ð $Ð Ø#Ð Ø" ZÑ/Ð Ø" ZÑ/Ð ð %€ð (Ð*;Ñ;Ð ð &Ð Ø'¨*Ñ4Ð ð (Ð*;Ñ;Ð ð 4°jÑ@Ð Ø(Ð ð "Ð Ø!Ð à˜9Ñ$€ð,ð ,ð ,ð ,ð ,Ð/ñ ,ô ,ð ,ð"n,ð n,ð n,ð n,ð n,�iñ n,ô n,ð n,ðb%ð %ð %ð %ð %r%   