Ë
    Áj­K  ã                  óâ  — 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
 dd	lmZ dd
lmZ ddlmZ ddlZddlZddlmc mZ ej*                  dz   ej,                  z   Zej*                  dz   ej,                  z   Z ej2                  d«      Z ej2                  d«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de
«      Z G d„ de
«      Z  G d„ de
«      Z! G d„ de«      Z"d„ Z#y) zŠ
Adds footnote handling to Python-Markdown.

See the [documentation](https://Python-Markdown.github.io/extensions/footnotes)
for details.
é    )Úannotationsé   )Ú	Extensioné   )ÚBlockProcessor)ÚInlineProcessor)ÚTreeprocessor)ÚPostprocessor)Úutil)ÚOrderedDictNÚzz1337820767766393qqÚqq3936677670287331zzz(fnref)(\d+)z(?<!!)\[\^([^\]]*)\](?!\s*:)c                  ó|   ‡ — e Zd ZdZˆ fd„Zd„ Zdd„Zddd„Z	 	 	 	 dd„Zdd„Z	dd„Z
dd	„Zdd
„Zddd„Zdd„Zˆ xZS )ÚFootnoteExtensionz Footnote Extension. c                ó  •— ddgddgddgddgd	d
gddgddgdœ| _         	 t        ‰| �  di |¤Ž d| _        i | _        t        «       | _        | j                  d| j                  d«      j                  dd«      «       | j                  «        y)z Setup configs. z///Footnotes Go Here///z1The text string that marks where the footnotes goFz9Avoid name collisions across multiple calls to `reset()`.z&#8617;zCThe text string that links from the footnote to the reader's place.z{}zCThe text string that links from the reader's place to the footnote.z$Jump back to footnote %d in the textznThe text string used for the title HTML attribute of the backlink. %d will be replaced by the footnote number.Ú:zFootnote separator.Tz]Order footnote labels by definition order (True) or by document order (False). Default: True.)ÚPLACE_MARKERÚ
UNIQUE_IDSÚBACKLINK_TEXTÚSUPERSCRIPT_TEXTÚBACKLINK_TITLEÚ	SEPARATORÚUSE_DEFINITION_ORDERr   r   z%dN© )ÚconfigÚsuperÚ__init__Úunique_prefixÚ
found_refsÚsetÚ	used_refsÚ	setConfigÚ	getConfigÚreplaceÚreset)ÚselfÚkwargsÚ	__class__s     €úP/var/www/html/venv/lib/python3.12/site-packages/markdown/extensions/footnotes.pyr   zFootnoteExtension.__init__*   sÍ   ø€ ð
 *Ð+^ðð ÐRðð Ð`ðð Ð[ð!ð 7ð>ðð Ð*ðð ð!ð%ñ+
ˆŒð6 	/Ü‰ÑÑ"˜6Ò"ð ˆÔØ*,ˆŒÜ#&£5ˆŒð 	�‰Ð'¨¯©Ð8HÓ)I×)QÑ)QÐRVÐX\Ó)]Ô^à�
‰
�ó    c                óZ  — |j                  | «       |j                  | _        || _        |j                  j                  j	                  t        | «      dd«       d}|j                  j	                  t        || «      dd«       |j                  j	                  t        | «      dd«       | j                  d«      s&|j                  j	                  t        | «      dd«       |j                  j	                  t        | «      d	d
«       |j                  j	                  t        | «      dd«       y)z Add pieces to Markdown. Úfootnoteé   z\[\^([^\]]*)\]é¯   é2   r   zfootnote-reorderé   zfootnote-duplicateé   é   N)ÚregisterExtensionÚparserÚmdÚblockprocessorsÚregisterÚFootnoteBlockProcessorÚinlinePatternsÚFootnoteInlineProcessorÚtreeprocessorsÚFootnoteTreeprocessorr#   ÚFootnoteReorderingProcessorÚFootnotePostTreeprocessorÚpostprocessorsÚFootnotePostprocessor)r&   r5   ÚFOOTNOTE_REs      r)   ÚextendMarkdownz FootnoteExtension.extendMarkdownU   sþ   € à
×Ñ˜TÔ"Ø—i‘iˆŒØˆŒà
�	‰	×!Ñ!×*Ñ*Ô+AÀ$Ó+GÈÐUWÔXð (ˆØ
×Ñ×"Ñ"Ô#:¸;ÈÓ#MÈzÐ[^Ô_ð 	×Ñ×"Ñ"Ô#8¸Ó#>À
ÈBÔOð
 �~‰~Ð4Ô5Ø×Ñ×&Ñ&Ô'BÀ4Ó'HÐJ\Ð^`Ôað 	×Ñ×"Ñ"Ô#<¸TÓ#BÐDXÐZ\Ô]ð 	×Ñ×"Ñ"Ô#8¸Ó#>À
ÈBÕOr*   c                ó†   — g | _         t        «       | _        | xj                  dz  c_        i | _        t        «       | _        y)z> Clear footnotes on reset, and prepare for distinct document. r   N)Úfootnote_orderr   Ú	footnotesr   r   r    r!   ©r&   s    r)   r%   zFootnoteExtension.resett   s4   € à)+ˆÔÜ0;³ˆŒØ×Ò˜aÑÕØˆŒÜ›ˆ�r*   c                ó  — |s|S |}|| j                   v r¢|j                  | j                  «       d«      \  }}t        j	                  |«      }|rBd|j                  d«      t        |j                  d«      «      dz   | j                  «       |fz  }nd|d| j                  «       |fz  }|| j                   v rŒ¢| j                   j                  |«       || j                  v r| j                  |xx   dz  cc<   |S d| j                  |<   |S )z1 Get a unique reference if there are duplicates. r   ú%s%d%s%sr   )	r!   ÚsplitÚget_separatorÚ	RE_REF_IDÚmatchÚgroupÚintÚaddr   )r&   Ú	referenceÚfoundÚoriginal_refÚrefÚrestÚms          r)   Ú
unique_refzFootnoteExtension.unique_ref|   sü   € áØÐà ˆØ˜4Ÿ>™>Ñ)Ø!Ÿ™¨×(:Ñ(:Ó(<¸aÓ@‰IˆC�Ü—‘ Ó$ˆAÙØ&¨!¯'©'°!«*´c¸!¿'¹'À!»*³oÀaÑ6GÈ×I[ÑI[ÓI]Ð_cÐ)dÑd‘	à&¨#¨q°$×2DÑ2DÓ2FÈÐ)MÑM�	ð ˜4Ÿ>™>Ò)ð 	�‰×Ñ˜9Ô%Ø˜4Ÿ?™?Ñ*Ø�O‰O˜LÓ)¨QÑ.Ó)ð Ðð -.ˆD�O‰O˜LÑ)ØÐr*   c                ó&   ‡ ‡— ˆˆ fd„Š ‰|«      }|S )z@ Return ElementTree Element that contains Footnote placeholder. c                ó0  •— | D ]�  }|j                   r4|j                   j                  ‰j                  d«      «      dkD  r|| dfc S |j                  r4|j                  j                  ‰j                  d«      «      dkD  r|| dfc S  ‰|«      }|€ŒŽ|c S  y )Nr   éÿÿÿÿTF)ÚtextÚfindr#   Útail)ÚelementÚchildÚ	child_resÚfinderr&   s      €€r)   r`   z:FootnoteExtension.findFootnotesPlaceholder.<locals>.finder•   s‹   ø€ Û �Ø—:’:Ø—z‘z—‘ t§~¡~°nÓ'EÓFÈÒKØ$ g¨tÐ3Ò3Ø—:’:Ø—z‘z—‘ t§~¡~°nÓ'EÓFÈÒKØ$ g¨uÐ4Ò4Ù" 5›M�	ØÑ(Ø$Ò$ð !ð r*   r   )r&   ÚrootÚresr`   s   `  @r)   ÚfindFootnotesPlaceholderz*FootnoteExtension.findFootnotesPlaceholder‘   s   ù€ õ	ñ �T‹lˆØˆ
r*   c                ó"   — || j                   |<   y)z' Store a footnote for later retrieval. N©rE   )r&   ÚidrZ   s      r)   ÚsetFootnotezFootnoteExtension.setFootnote¥   s   € à!ˆ�‰�rÒr*   c                óX   — || j                   vr| j                   j                  |«       yy)z7 Store a footnote reference id in order of appearance. N)rD   Úappend©r&   rf   s     r)   ÚaddFootnoteRefz FootnoteExtension.addFootnoteRef©   s)   € à�T×(Ñ(Ñ(Ø×Ñ×&Ñ& rÕ*ð )r*   c                ó$   — | j                  d«      S )z Get the footnote separator. r   )r#   rF   s    r)   rJ   zFootnoteExtension.get_separator®   s   € à�~‰~˜kÓ*Ð*r*   c                ó¤   — | j                  d«      r d| j                  «       | j                  |fz  S dj                  | j                  «       |«      S )z Return footnote link id. r   z	fn%s%d-%szfn{}{})r#   rJ   r   Úformatrj   s     r)   ÚmakeFootnoteIdz FootnoteExtension.makeFootnoteId²   sI   € à�>‰>˜,Ô'Ø $×"4Ñ"4Ó"6¸×8JÑ8JÈBÐ!OÑOÐOà—?‘? 4×#5Ñ#5Ó#7¸Ó<Ð<r*   c                óä   — | j                  d«      r0| j                  d| j                  «       | j                  |fz  |«      S | j                  dj	                  | j                  «       |«      |«      S )z Return footnote back-link id. r   zfnref%s%d-%sz	fnref{}{})r#   rV   rJ   r   rn   )r&   rf   rQ   s      r)   ÚmakeFootnoteRefIdz#FootnoteExtension.makeFootnoteRefId¹   sd   € à�>‰>˜,Ô'Ø—?‘? >°T×5GÑ5GÓ5IÈ4×K]ÑK]Ð_aÐ4bÑ#bÐdiÓjÐjà—?‘? ;×#5Ñ#5°d×6HÑ6HÓ6JÈBÓ#OÐQVÓWÐWr*   c                ó’  — t        | j                  j                  «       «      syt        j                  d«      }|j                  dd«       t        j                  |d«       t        j                  |d«      }t        j                  d«      }t        | j                  j                  «       d¬«      D �]‘  \  }}t        j                  |d	«      }|j                  d
| j                  |«      «       | j                  j                  || j                  |   «       t        |«      D ]$  }|j                  |«       |j                  |«       Œ& t        j                  d«      }	|	j                  dd| j                  |«      z   «       |	j                  dd«       |	j                  d| j                  d«      j                  |«      «       t         |	_        t%        |«      s�Œ,|d   }
|
j&                  dk(  r+|
j"                  t(        z   |
_        |
j                  |	«       �Œkt        j                  |d«      }|j                  |	«       �Œ” |S )z/ Return `div` of footnotes as `etree` Element. NÚdivÚclassr,   ÚhrÚolr   ©ÚstartÚlirf   ÚaÚhrefÚ#úfootnote-backrefÚtitler   rY   Úp)ÚlistrE   ÚkeysÚetreeÚElementr    Ú
SubElementÚ	enumeratero   r4   Ú
parseChunkri   Úremoverq   r#   rn   ÚFN_BACKLINK_TEXTrZ   ÚlenÚtagÚNBSP_PLACEHOLDER)r&   ra   rs   rv   Úsurrogate_parentÚindexrf   ry   ÚelÚbacklinkÚnoder   s               r)   ÚmakeFootnotesDivz"FootnoteExtension.makeFootnotesDivÀ   sÍ  € ô �D—N‘N×'Ñ'Ó)Ô*Øä�m‰m˜EÓ"ˆØ�‰�˜Ô$Ü×Ñ˜˜dÔ#Ü×Ñ˜c 4Ó(ˆÜ Ÿ=™=¨Ó/Ðä" 4§>¡>×#6Ñ#6Ó#8À×BÐB‰IˆE�2Ü×!Ñ! " dÓ+ˆBØ�F‰F�4˜×,Ñ,¨RÓ0Ô1ð �K‰K×"Ñ"Ð#3°T·^±^ÀBÑ5GÔHÜÐ+Ö,�Ø—	‘	˜"”Ø ×'Ñ'¨Õ+ð -ô —}‘} SÓ)ˆHØ�L‰L˜  t×'=Ñ'=¸bÓ'AÑ!AÔBØ�L‰L˜Ð"4Ô5Ø�L‰LØØ—‘Ð/Ó0×7Ñ7¸Ó>ôô -ˆHŒMä�2ŽwØ˜"‘v�Ø—8‘8˜s’?Ø $§	¡	Ô,<Ñ <�D”IØ—K‘K Ö)ä×(Ñ(¨¨SÓ1�AØ—H‘H˜XÖ&ð5 Cð6 ˆ
r*   )ÚreturnÚNone)F)rP   ÚstrrQ   Úboolr’   r”   )ra   úetree.Elementr’   z0tuple[etree.Element, etree.Element, bool] | None)rf   r”   rZ   r”   r’   r“   )rf   r”   r’   r“   )r’   r”   )rf   r”   r’   r”   )rf   r”   rQ   r•   r’   r”   )ra   r–   r’   zetree.Element | None)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   rB   r%   rV   rc   rg   rk   rJ   ro   rq   r‘   Ú__classcell__©r(   s   @r)   r   r   '   sP   ø„ Ùô)òVPó>ôð*Ø!ðà	9óó("ó+ó
+ó=ôX÷'r*   r   c                  ó~   ‡ — e Zd ZdZ ej
                  dej                  «      Zdˆ fd„Zd	d„Z	d
d„Z
dd„Zdd„Zˆ xZS )r8   z4 Find footnote definitions and store for later use. z!^[ ]{0,3}\[\^([^\]]*)\]:[ ]*(.*)$c                óF   •— t         ‰| �  |j                  «       || _        y ©N)r   r   r4   rE   )r&   rE   r(   s     €r)   r   zFootnoteBlockProcessor.__init__ï   s   ø€ Ü‰Ñ˜×)Ñ)Ô*Ø"ˆ�r*   c                 ó   — y)NTr   )r&   ÚparentÚblocks      r)   ÚtestzFootnoteBlockProcessor.testó   s   € Ør*   c                ó  — |j                  d«      }| j                  j                  |«      }|�rÅ|j                  d«      }|j                  d«      g}||j	                  «       d j                  d«      }| j                  j                  |«      }|r}|d|j                  «        j                  d«      }	dj                  |d   | j                  |	«      g«      j                  d«      |d<   |j                  d||j                  «       d «       nWdj                  |d   | j                  |«      g«      j                  d«      |d<   |j                  | j                  |«      «       dj                  |«      }
| j                  j                  ||
j                  «       «       |d|j                  «        j                  «       r2|j                  d|d|j                  «        j                  d«      «       y|j                  d|«       y)	z- Find, set, and remove footnote definitions. r   r   r   NÚ
z

TF)ÚpopÚREÚsearchrM   ÚendÚlstriprx   ÚrstripÚjoinÚdetabÚinsertÚstripÚextendÚdetectTabbedrE   rg   )r&   r¡   Úblocksr¢   rU   rf   Ú	fn_blocksÚtherestÚm2Úbeforer,   s              r)   ÚrunzFootnoteBlockProcessor.runö   s¦  € à—
‘
˜1“ˆà�G‰G�N‰N˜5Ó!ˆÚØ—‘˜“ˆBØŸ™ ›˜ˆIð ˜AŸE™E›G˜H�o×,Ñ,¨TÓ2ˆGØ—‘—‘ Ó(ˆBÙð !  "§(¡(£*Ð-×4Ñ4°TÓ:�Ø#Ÿy™y¨)°A©,¸¿
¹
À6Ó8JÐ)KÓL×SÑSÐTXÓY�	˜!‘à—‘˜a ¨¯©«¨Ð!5Õ6ð  $Ÿy™y¨)°A©,¸¿
¹
À7Ó8KÐ)LÓM×SÑSÐTXÓY�	˜!‘ð × Ñ  ×!2Ñ!2°6Ó!:Ô;à—{‘{ 9Ó-ˆHØ�N‰N×&Ñ& r¨8¯?©?Ó+<Ô=à�Z�a—g‘g“iÐ ×&Ñ&Ô(à—‘˜a  z¨¯©«	Ð!2×!9Ñ!9¸$Ó!?Ô@Øà�‰�a˜ÔØr*   c                ó°  — g }|rÑ|d   j                  d«      r·|j                  d«      }| j                  j                  |«      }|rh|d|j	                  «        j                  d«      }|j                  | j                  |«      «       |j                  d||j	                  «       d «       	 |S |j                  | j                  |«      «       n	 |S |rŒÑ|S )z’ Find indented text and remove indent before further processing.

        Returns:
            A list of blocks with indentation removed.
        r   ú    Nr¥   )	Ú
startswithr¦   r§   r¨   rx   r«   ri   r­   r®   )r&   r²   r³   r¢   rU   r¶   s         r)   r±   z#FootnoteBlockProcessor.detectTabbed  sÍ   € ð ˆ	ÙØ�a‰y×#Ñ# EÔ*ØŸ
™
 1›�à—G‘G—N‘N 5Ó)�Ùð # : A§G¡G£IÐ.×5Ñ5°dÓ;�FØ×$Ñ$ T§Z¡Z°Ó%7Ô8à—M‘M ! U¨1¯7©7«9¨:Ð%6Ô7àð Ðð	 ×$Ñ$ T§Z¡Z°Ó%6Õ7ð ØÐò) ð( Ðr*   c                ó    — |j                  d«      }t        |«      D ]  \  }}|j                  d«      sŒ|dd ||<   Œ! dj                  |«      S )zˆ Remove one level of indent from a block.

        Preserve lazily indented blocks by only removing indent from indented lines.
        r¥   r¹   é   N)rI   r…   rº   r¬   )r&   r¢   ÚlinesÚiÚlines        r)   r­   zFootnoteBlockProcessor.detab8  sQ   € ð
 —‘˜DÓ!ˆÜ  Ö'‰GˆAˆtØ�‰˜uÕ%Ø  ˜8��a’ð (ð �y‰y˜ÓÐr*   ©rE   r   )r¡   r–   r¢   r”   r’   r•   )r¡   r–   r²   ú	list[str]r’   r•   )r²   rÁ   r’   rÁ   )r¢   r”   r’   r”   )r—   r˜   r™   rš   ÚreÚcompileÚ	MULTILINEr§   r   r£   r·   r±   r­   r›   rœ   s   @r)   r8   r8   ê   s7   ø„ Ù>à	ˆ�‰Ð8¸"¿,¹,Ó	G€Bõ#óó#óJ÷:	 r*   r8   c                  ó,   ‡ — e Zd ZdZdˆ fd„Zdd„Zˆ xZS )r:   zC `InlineProcessor` for footnote markers in a document's body text. c                ó2   •— t         ‰| �  |«       || _        y rŸ   )r   r   rE   )r&   ÚpatternrE   r(   s      €r)   r   z FootnoteInlineProcessor.__init__G  s   ø€ Ü‰Ñ˜Ô!Ø"ˆ�r*   c                ó„  — |j                  d«      }|| j                  j                  j                  «       v �rˆ| j                  j                  |«       | j                  j	                  d«      s)| j                  j
                  j                  |«      dz   }n?t        | j                  j                  j                  «       «      j                  |«      dz   }t        j                  d«      }t        j                  |d«      }|j                  d| j                  j                  |d¬«      «       |j                  dd	| j                  j                  |«      z   «       |j                  d
d«       | j                  j	                  d«      j                  |«      |_        ||j!                  d«      |j#                  d«      fS y)Nr   r   Úsuprz   rf   T)rQ   r{   r|   rt   zfootnote-refr   r   )NNN)rM   rE   r�   rk   r#   rD   r�   r€   r‚   rƒ   r„   r    rq   ro   rn   rZ   rx   r©   )r&   rU   Údatarf   Úfootnote_numrÉ   rz   s          r)   ÚhandleMatchz#FootnoteInlineProcessor.handleMatchK  sR  € Ø�W‰W�Q‹ZˆØ�—‘×)Ñ)×.Ñ.Ó0Ò0Ø�N‰N×)Ñ)¨"Ô-à—>‘>×+Ñ+Ð,BÔCà#Ÿ~™~×<Ñ<×BÑBÀ2ÓFÈÑJ‘ô  $ D§N¡N×$<Ñ$<×$AÑ$AÓ$CÓD×JÑJÈ2ÓNÐQRÑR�ä—-‘- Ó&ˆCÜ× Ñ   cÓ*ˆAØ�G‰G�D˜$Ÿ.™.×:Ñ:¸2ÀTÐ:ÓJÔKØ�E‰E�&˜# §¡× =Ñ =¸bÓ AÑAÔBØ�E‰E�'˜>Ô*Ø—^‘^×-Ñ-Ð.@ÓA×HÑHÈÓVˆAŒFØ˜Ÿ™ ›
 A§E¡E¨!£HÐ,Ð,à#r*   )rÇ   r”   rE   r   )rU   zre.Match[str]rÊ   r”   r’   z3tuple[etree.Element | None, int | None, int | None])r—   r˜   r™   rš   r   rÌ   r›   rœ   s   @r)   r:   r:   D  s   ø„ ÙMõ#÷$r*   r:   c                  ó8   — e Zd ZdZdd„Zd	d„Zd
d„Zdd„Zdd„Zy)r>   z% Amend footnote div with duplicates. c                ó   — || _         y rŸ   re   ©r&   rE   s     r)   r   z"FootnotePostTreeprocessor.__init__e  ó	   € Ø"ˆ�r*   c                ó2  — |j                  d«      D �]  }|j                  j                  dd«      dk(  sŒ$|j                  d   j                  | j                  j                  «       d«      \  }}g }t        d|dz   «      D ]k  }t        j                  |«      }d||| j                  j                  «       |fz  |j                  d<   |j                  |«       | xj                  dz  c_
        Œm t        |«      d	   }	|D ]  }|	j                  |«       Œ  y
 y
)zF Adjust current `li` and add the duplicates: `fnref2`, `fnref3`, etc. rz   rt   Ú r}   r{   r   r   rH   rY   N)ÚiterÚattribÚgetrI   rE   rJ   ÚrangeÚcopyÚdeepcopyri   Úoffsetr€   )
r&   ry   Ú
duplicatesÚlinkrS   rT   Úlinksr�   Úsib_linkrŽ   s
             r)   Úadd_duplicatesz(FootnotePostTreeprocessor.add_duplicatesh  sî   € à—G‘G˜C—LˆDà�{‰{�‰˜w¨Ó+Ð/AÓAØ ŸK™K¨Ñ/×5Ñ5°d·n±n×6RÑ6RÓ6TÐVWÓX‘	��Tð �Ü" 1 j°1¡nÖ5�EÜ#Ÿ}™}¨TÓ2�HØ.8¸CÀÈÏÉ×HdÑHdÓHfÐhlÐ;mÑ.m�H—O‘O FÑ+Ø—L‘L Ô*Ø—K’K 1Ñ$–Kð	 6ô ˜"“X˜b‘\�Û!�DØ—I‘I˜d•Oð "áñ! !r*   c                ó2  — |j                   j                  dd«      j                  | j                  j	                  «       d«      \  }}dj                  || j                  j	                  «       |«      }| j                  j                  j                  |d«      S )z3 Get the number of duplicate refs of the footnote. rf   rÒ   r   z	{}ref{}{}r   )rÔ   rÕ   rI   rE   rJ   rn   r   )r&   ry   ÚfnrT   Úlink_ids        r)   Úget_num_duplicatesz,FootnotePostTreeprocessor.get_num_duplicates|  ss   € à—9‘9—=‘=  rÓ*×0Ñ0°·±×1MÑ1MÓ1OÐQRÓS‰ˆˆDØ×$Ñ$ R¨¯©×)EÑ)EÓ)GÈÓNˆØ�~‰~×(Ñ(×,Ñ,¨W°aÓ8Ð8r*   c                óv   — t        |«      D ]+  }| j                  |«      }|dkD  sŒ| j                  ||«       Œ- y)z= Find duplicate footnotes and format and add the duplicates. r   N)r€   râ   rÞ   )r&   r¡   ry   Úcounts       r)   Úhandle_duplicatesz+FootnotePostTreeprocessor.handle_duplicates‚  s9   € ä�v–,ˆBð ×+Ñ+¨BÓ/ˆEØ�q‹yØ×#Ñ# B¨Õ.ñ r*   c                óÎ   — d| _         |j                  d«      D ]J  }|j                  j                  dd«      dk(  sŒ#|j                  d«      D ]  }| j	                  |«        ŒJ ŒL y)z= Crawl the footnote div and add missing duplicate footnotes. r   rs   rt   rÒ   r,   rv   N)rÙ   rÓ   rÔ   rÕ   rå   )r&   ra   rs   rv   s       r)   r·   zFootnotePostTreeprocessor.run‹  sX   € àˆŒØ—9‘9˜UÖ#ˆCØ�z‰z�~‰~˜g rÓ*¨jÓ8ð Ÿ(™( 4ž.�BØ×*Ñ*¨2Ô.Ùñ )ñ	 $r*   NrÀ   )ry   r–   rÚ   rN   r’   r“   )ry   r–   r’   rN   ©r¡   r–   r’   r“   ©ra   r–   r’   r“   )	r—   r˜   r™   rš   r   rÞ   râ   rå   r·   r   r*   r)   r>   r>   b  s   „ Ù/ó#óó(9ó/ô	r*   r>   c                  ó    — e Zd ZdZdd„Zdd„Zy)r<   z3 Build and append footnote div to end of document. c                ó   — || _         y rŸ   re   rÏ   s     r)   r   zFootnoteTreeprocessor.__init__š  rÐ   r*   c                ób  — | j                   j                  |«      }|�’| j                   j                  |«      }|rc|\  }}}t        |«      j	                  |«      }|r$|j                  |«       |j                  ||«       y |j                  |dz   |«       d |_        y |j                  |«       y y )Nr   )	rE   r‘   rc   r€   r�   r‡   r®   r\   ri   )r&   ra   ÚfootnotesDivÚresultr^   r¡   ÚisTextÚinds           r)   r·   zFootnoteTreeprocessor.run�  sš   € Ø—~‘~×6Ñ6°tÓ<ˆØÐ#Ø—^‘^×<Ñ<¸TÓBˆFÙØ(.Ñ%��v˜vÜ˜6“l×(Ñ(¨Ó/�ÙØ—M‘M %Ô(Ø—M‘M # |Õ4à—M‘M #¨¡'¨<Ô8Ø!%�E•Jà—‘˜LÕ)ð $r*   NrÀ   rè   ©r—   r˜   r™   rš   r   r·   r   r*   r)   r<   r<   —  s   „ Ù=ó#ô*r*   r<   c                  ó(   — e Zd ZdZdd„Zdd„Zdd„Zy)	r=   z* Reorder list items in the footnotes div. c                ó   — || _         y rŸ   re   rÏ   s     r)   r   z$FootnoteReorderingProcessor.__init__±  rÐ   r*   c                óL  — | j                   j                   sy | j                   j                  t        | j                   j                   j                  «       «      k7  rI|j	                  d«      D ]4  }|j
                  j                  dd«      dk(  sŒ#| j                  |«        y  y y )Nrs   rt   rÒ   r,   )rE   rD   r€   r�   rÓ   rÔ   rÕ   Úreorder_footnotes)r&   ra   rs   s      r)   r·   zFootnoteReorderingProcessor.run´  s}   € Ø�~‰~×'Ò'ØØ�>‰>×(Ñ(¬D°·±×1IÑ1I×1NÑ1NÓ1PÓ,QÒQØ—y‘y Ö'�Ø—:‘:—>‘> '¨2Ó.°*Ó<Ø×*Ñ*¨3Ô/Ùñ (ð Rr*   c                ó   ‡ — |j                  d«      }|j                  |«       |j                  d«      }d
ˆ fd„}t        ||¬«      }t	        j
                  |d«      }t        |d¬«      D ]a  \  }}|j                  d«      }|j                  d‰ j                  j                  d	«      j                  |«      «       |j                  |«       Œc y )Nrv   ry   c                óJ  •— | j                   j                  dd«      j                  ‰j                  j	                  «       d«      d   }|‰j                  j
                  v r%‰j                  j
                  j                  |«      S t        ‰j                  j                  «      S )Nrf   rÒ   r   rY   )rÔ   rÕ   rI   rE   rJ   rD   r�   r‰   )ry   rf   r&   s     €r)   Úorder_by_idzBFootnoteReorderingProcessor.reorder_footnotes.<locals>.order_by_idÂ  sƒ   ø€ Ø—‘—‘˜t RÓ(×.Ñ.¨t¯~©~×/KÑ/KÓ/MÈqÓQÐRTÑUˆBð ˜Ÿ™×6Ñ6Ñ6ð —‘×-Ñ-×3Ñ3°BÓ7ðô ˜Ÿ™×1Ñ1Ó2ðr*   )Úkeyr   rw   z.//a[@class="footnote-backref"]r~   r   )r’   rN   )r[   r‡   ÚfindallÚsortedr‚   r„   r…   r    rE   r#   rn   ri   )	r&   r¡   Úold_listÚitemsr÷   Únew_listr�   Úitemr�   s	   `        r)   rô   z-FootnoteReorderingProcessor.reorder_footnotes½  s¬   ø€ Ø—;‘;˜tÓ$ˆØ�‰�hÔØ× Ñ  Ó&ˆõ	ô �u +Ô.ˆä×#Ñ# F¨DÓ1ˆä$ U°!×4‰KˆE�4Ø—y‘yÐ!BÓCˆHØ�L‰L˜ $§.¡.×":Ñ":Ð;KÓ"L×"SÑ"SÐTYÓ"ZÔ[Ø�O‰O˜DÕ!ñ 5r*   NrÀ   rè   rç   )r—   r˜   r™   rš   r   r·   rô   r   r*   r)   r=   r=   ®  s   „ Ù4ó#óô"r*   r=   c                  ó    — e Zd ZdZdd„Zdd„Zy)r@   z* Replace placeholders with html entities. c                ó   — || _         y rŸ   re   rÏ   s     r)   r   zFootnotePostprocessor.__init__Ö  rÐ   r*   c                óŒ   — |j                  t        | j                  j                  d«      «      }|j                  t        d«      S )Nr   z&#160;)r$   rˆ   rE   r#   r‹   )r&   rZ   s     r)   r·   zFootnotePostprocessor.runÙ  s8   € Ø�|‰|Ü˜dŸn™n×6Ñ6°ÓGó
ˆð �|‰|Ô,¨hÓ7Ð7r*   NrÀ   )rZ   r”   r’   r”   rð   r   r*   r)   r@   r@   Ô  s   „ Ù4ó#ô8r*   r@   c                 ó   — t        di | ¤ŽS )z/ Return an instance of the `FootnoteExtension` r   )r   )r'   s    r)   ÚmakeExtensionr  à  s   € äÑ&˜vÑ&Ð&r*   )$rš   Ú
__future__r   rÒ   r   r6   r   Úinlinepatternsr   r;   r	   r?   r
   r   Úcollectionsr   rÂ   r×   Úxml.etree.ElementTreer‚   ÚElementTreeÚSTXÚETXrˆ   r‹   rÃ   rK   ÚRE_REFERENCEr   r8   r:   r>   r<   r=   r@   r  r   r*   r)   Ú<module>r     sä   ðñõ #å Ý ,Ý ,Ý *Ý *Ý Ý #Û 	Û ß %Ð %à—8‘8Ð4Ñ4°t·x±xÑ?Ð Ø—8‘8Ð4Ñ4°t·x±xÑ?Ð ØˆB�J‰J�Ó'€	Øˆr�z‰zÐ9Ó:€ô@˜	ô @ôFW ˜^ô W ôt$˜oô $ô<2 ô 2ôj*˜Mô *ô.#" -ô #"ôL	8˜Mô 	8ó'r*   