§
    Ó¼Ñbr  ã                   ó®   — 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	Z	ddl
mc mZ  G d	„ d
e¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Zd„ ZdS )aç  
Abbreviation Extension for Python-Markdown
==========================================

This extension adds abbreviation handling to Python-Markdown.

See <https://Python-Markdown.github.io/extensions/abbreviations>
for documentation.

Oringinal code Copyright 2007-2008 [Waylan Limberg](http://achinghead.com/) and
 [Seemant Kulleen](http://www.kulleen.org/)

All changes Copyright 2008-2014 The Python Markdown Project

License: [BSD](https://opensource.org/licenses/bsd-license.php)

é   )Ú	Extensioné   )ÚBlockProcessor)ÚInlineProcessor)ÚAtomicStringé    Nc                   ó   — e Zd ZdZd„ ZdS )ÚAbbrExtensionz- Abbreviation Extension for Python-Markdown. c                 ól   — |j         j                             t          |j         ¦  «        dd¦  «         dS )z7 Insert AbbrPreprocessor before ReferencePreprocessor. Úabbré   N)ÚparserÚblockprocessorsÚregisterÚAbbrPreprocessor)ÚselfÚmds     ú:/usr/lib/python3/dist-packages/markdown/extensions/abbr.pyÚextendMarkdownzAbbrExtension.extendMarkdown   s1   € à
Œ	Ô!×*Ò*Õ+;¸B¼IÑ+FÔ+FÈÐPRÑSÔSÐSÐSÐSó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   © r   r   r
   r
      s.   € € € € € Ø7Ð7ðTð Tð Tð Tð Tr   r
   c                   óP   — e Zd ZdZ ej        dej        ¦  «        Zd„ Zd„ Z	d„ Z
dS )r   z= Abbreviation Preprocessor - parse text for abbr references. z6^[*]\[(?P<abbr>[^\]]*)\][ ]?:[ ]*\n?[ ]*(?P<title>.*)$c                 ó   — dS )NTr   )r   ÚparentÚblocks      r   ÚtestzAbbrPreprocessor.test(   s   € Øˆtr   c                 óŽ  — |                      d¦  «        }| j                             |¦  «        }|�r||                     d¦  «                             ¦   «         }|                     d¦  «                             ¦   «         }| j        j        j                             t          |  
                    |¦  «        |¦  «        d|z  d¦  «         ||                     ¦   «         d…                              ¦   «         rC|                     d||                     ¦   «         d…                              d¦  «        ¦  «         |d|                     ¦   «         …                              ¦   «         rC|                     d|d|                     ¦   «         …                              d¦  «        ¦  «         dS |                     d|¦  «         d	S )
zš
        Find and remove all Abbreviation references from the text.
        Each reference is set as a new AbbrPattern in the markdown instance.

        r   r   Útitlezabbr-%sr   Nú
TF)ÚpopÚREÚsearchÚgroupÚstripr   r   ÚinlinePatternsr   ÚAbbrInlineProcessorÚ_generate_patternÚendÚinsertÚlstripÚstartÚrstrip)r   r   Úblocksr   Úmr   r"   s          r   ÚrunzAbbrPreprocessor.run+   sz  € ð —
’
˜1‘”ˆØŒG�NŠN˜5Ñ!Ô!ˆØñ 	Ø—7’7˜6‘?”?×(Ò(Ñ*Ô*ˆDØ—G’G˜GÑ$Ô$×*Ò*Ñ,Ô,ˆEØŒKŒNÔ)×2Ò2Ý# D×$:Ò$:¸4Ñ$@Ô$@À%ÑHÔHÈ)ÐVZÑJZÐ\]ñô ð ð �Q—U’U‘W”W�X�XŒ×$Ò$Ñ&Ô&ð ?à—’˜a  q§u¢u¡w¤w x x¤×!7Ò!7¸Ñ!=Ô!=Ñ>Ô>Ð>Ø�Z�a—g’g‘i”i�ZÔ ×&Ò&Ñ(Ô(ð Aà—’˜a  z¨¯ª©	¬	 zÔ!2×!9Ò!9¸$Ñ!?Ô!?Ñ@Ô@Ð@Ø�4à�Š�a˜ÑÔÐØˆur   c                 óª   — t          |¦  «        }t          t          |¦  «        ¦  «        D ]}d||         z  ||<   Œdd                     |¦  «        z  S )zø
        Given a string, returns an regex pattern to match that string.

        'HTML' -> r'(?P<abbr>[H][T][M][L])'

        Note: we force each char as a literal match (in brackets) as we don't
        know what they will be beforehand.

        z[%s]z(?P<abbr>\b%s\b)Ú )ÚlistÚrangeÚlenÚjoin)r   ÚtextÚcharsÚis       r   r+   z"AbbrPreprocessor._generate_patternD   sU   € õ �T‘
”
ˆÝ•s˜5‘z”zÑ"Ô"ð 	*ð 	*ˆAØ  q¤Ñ)ˆE�!‰HˆHØ" c§h¢h¨u¡o¤oÑ6Ð6r   N)r   r   r   r   ÚreÚcompileÚ	MULTILINEr%   r    r3   r+   r   r   r   r   r   #   s]   € € € € € ØGÐGà	ˆŒÐMÈrÌ|Ñ	\Ô	\€Bðð ð ðð ð ð27ð 7ð 7ð 7ð 7r   r   c                   ó(   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ xZS )r*   z Abbreviation inline pattern. c                 óX   •— t          ¦   «                              |¦  «         || _        d S )N)ÚsuperÚ__init__r"   )r   Úpatternr"   Ú	__class__s      €r   rC   zAbbrInlineProcessor.__init__W   s&   ø€ Ý‰Œ×Ò˜Ñ!Ô!Ð!ØˆŒ
ˆ
ˆ
r   c                 ó  — t          j        d¦  «        }t          |                     d¦  «        ¦  «        |_        |                     d| j        ¦  «         ||                     d¦  «        |                     d¦  «        fS )Nr   r"   r   )	ÚetreeÚElementr   r'   r:   Úsetr"   r/   r,   )r   r2   Údatar   s       r   ÚhandleMatchzAbbrInlineProcessor.handleMatch[   sa   € ÝŒ}˜VÑ$Ô$ˆÝ  §¢¨¡¤Ñ1Ô1ˆŒ	Ø�Š�˜$œ*Ñ%Ô%Ð%Ø�Q—W’W˜Q‘Z”Z §¢ q¡¤Ð)Ð)r   )r   r   r   r   rC   rK   Ú__classcell__)rE   s   @r   r*   r*   T   sM   ø€ € € € € Ø(Ð(ðð ð ð ð ð*ð *ð *ð *ð *ð *ð *r   r*   c                  ó   — t          di | ¤ŽS )Nr   )r
   )Úkwargss    r   ÚmakeExtensionrO   b   s   € ÝÐ"Ð"˜6Ð"Ð"Ð"r   )r   r5   r   r   r   Úinlinepatternsr   Úutilr   r=   Úxml.etree.ElementTreerG   ÚElementTreer
   r   r*   rO   r   r   r   ú<module>rT      s  ððð ð$ Ð Ð Ð Ð Ð Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø Ð Ð Ð Ð Ð Ø 	€	€	€	Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ð %ðTð Tð Tð Tð T�Iñ Tô Tð Tð.7ð .7ð .7ð .7ð .7�~ñ .7ô .7ð .7ðb*ð *ð *ð *ð *˜/ñ *ô *ð *ð#ð #ð #ð #ð #r   