§
    )P„j’Q  ã                  óÞ  — 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j        d¦  «        Z ej        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#dS ) 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                  ót   ‡ — 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                óZ  •— ddgddgddgddgd	d
gddgddgdœ| _         	  t          ¦   «         j        di |¤Ž d| _        i | _        t          ¦   «         | _        |                      d|                      d¦  «         	                    dd¦  «        ¦  «         |  
                    ¦   «          dS )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     €úb/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/markdown/extensions/footnotes.pyr   zFootnoteExtension.__init__*   sõ   ø€ ð
 *Ð+^ðð ÐRðð Ð`ðð Ð[ð!ð 7ð>ðð Ð*ðð ð!ð%ð+
ð 
ˆŒð6 	/Ø�‰ŒÔÐ"Ð"˜6Ð"Ð"Ð"ð ˆÔØ*,ˆŒÝ#&¡5¤5ˆŒð 	�ŠÐ'¨¯ªÐ8HÑ)IÔ)I×)QÒ)QÐRVÐX\Ñ)]Ô)]Ñ^Ô^Ð^à�
Š
‰Œˆˆˆó    c                ó|  — |                      | ¦  «         |j        | _        || _        |j        j                             t          | ¦  «        dd¦  «         d}|j                             t          || ¦  «        dd¦  «         |j                             t          | ¦  «        dd¦  «         |  
                    d¦  «        s)|j                             t          | ¦  «        dd¦  «         |j                             t          | ¦  «        d	d
¦  «         |j                             t          | ¦  «        dd¦  «         dS )aÛ   Register the processors.

        | Class Instance                                                              | Registry                                                         | Name   | Priority |
        | --------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------ | :------: |
        | [`FootnoteBlockProcessor`][markdown.extensions.footnotes.FootnoteBlockProcessor] | [`blockprocessors`][markdown.blockprocessors.build_block_parser] | `footnote` | `17` |
        | [`FootnoteInlineProcessor`][markdown.extensions.footnotes.FootnoteInlineProcessor] | [`inlinepatterns`][markdown.inlinepatterns.build_inlinepatterns] | `footnote` | `175` |
        | [`FootnoteTreeprocessor`][markdown.extensions.footnotes.FootnoteTreeprocessor] | [`treeprocessors`][markdown.treeprocessors.build_treeprocessors] | `footnote` | `50` |
        | [`FootnoteReorderingProcessor`][markdown.extensions.footnotes.FootnoteReorderingProcessor] | [`treeprocessors`][markdown.treeprocessors.build_treeprocessors] | `footnote-reorder` | `19` |
        | [`FootnotePostTreeprocessor`][markdown.extensions.footnotes.FootnotePostTreeprocessor] | [`treeprocessors`][markdown.treeprocessors.build_treeprocessors] | `footnote-duplicate` | `15` |
        | [`FootnotePostprocessor`][markdown.extensions.footnotes.FootnotePostprocessor] | [`postprocessors`][markdown.postprocessors.build_postprocessors] | `footnote` | `25` |

        Ú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   s5  € ð 	×Ò˜TÑ"Ô"Ð"Ø”iˆŒØˆŒà
Œ	Ô!×*Ò*Õ+AÀ$Ñ+GÔ+GÈÐUWÑXÔXÐXð (ˆØ
Ô×"Ò"Õ#:¸;ÈÑ#MÔ#MÈzÐ[^Ñ_Ô_Ð_ð 	Ô×"Ò"Õ#8¸Ñ#>Ô#>À
ÈBÑOÔOÐOð
 �~Š~Ð4Ñ5Ô5ð 	bØÔ×&Ò&Õ'BÀ4Ñ'HÔ'HÐJ\Ð^`ÑaÔaÐað 	Ô×"Ò"Õ#<¸TÑ#BÔ#BÐDXÐZ\Ñ]Ô]Ð]ð 	Ô×"Ò"Õ#8¸Ñ#>Ô#>À
ÈBÑOÔOÐOÐOÐOr*   ÚreturnÚNonec                óŽ   — g | _         t          ¦   «         | _        | xj        dz  c_        i | _        t          ¦   «         | _        dS )z> Clear footnotes on reset, and prepare for distinct document. r   N)Úfootnote_orderr   Ú	footnotesr   r   r    r!   ©r&   s    r)   r%   zFootnoteExtension.reset€   s?   € à)+ˆÔÝ0;±´ˆŒØÐÔ˜aÑÐÔØˆŒÝ™œˆŒˆˆr*   FÚ	referenceÚstrÚfoundÚboolc                ó$  — |s|S |}|| j         v r½|                     |                      ¦   «         d¦  «        \  }}t                               |¦  «        }|rRd|                     d¦  «        t          |                     d¦  «        ¦  «        dz   |                      ¦   «         |fz  }nd|d|                      ¦   «         |fz  }|| j         v °½| j                              |¦  «         || j        v r| j        |xx         dz  cc<   n
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&   rI   rK   Úoriginal_refÚrefÚrestÚms          r)   Ú
unique_refzFootnoteExtension.unique_refˆ   s&  € àð 	ØÐà ˆØ˜4œ>Ð)Ð)Ø!Ÿš¨×(:Ò(:Ñ(<Ô(<¸aÑ@Ô@‰IˆC�Ý—’ Ñ$Ô$ˆAØð NØ&¨!¯'ª'°!©*¬*µc¸!¿'º'À!¹*¼*±o´oÀaÑ6GÈ×I[ÒI[ÑI]ÔI]Ð_cÐ)dÑd�	�	à&¨#¨q°$×2DÒ2DÑ2FÔ2FÈÐ)MÑM�	ð ˜4œ>Ð)Ð)ð 	Œ×Ò˜9Ñ%Ô%Ð%Ø˜4œ?Ð*Ð*ØŒO˜LÐ)Ð)Ô)¨QÑ.Ð)Ð)Ñ)Ð)à,-ˆDŒO˜LÑ)ØÐr*   Úrootúetree.Elementú0tuple[etree.Element, etree.Element, bool] | Nonec                ó,   ‡ ‡— ˆˆ fd„Š ‰|¦  «        }|S )z@ Return ElementTree Element that contains Footnote placeholder. c                ó0  •— | D ]‘}|j         r8|j                              ‰                     d¦  «        ¦  «        dk    r|| dfc S |j        r8|j                             ‰                     d¦  «        ¦  «        dk    r|| dfc S  ‰|¦  «        }|�|c S Œ’d S )Nr   éÿÿÿÿTF)ÚtextÚfindr#   Útail)ÚelementÚchildÚ	child_resÚfinderr&   s      €€r)   rg   z:FootnoteExtension.findFootnotesPlaceholder.<locals>.finder¡   s¿   ø€ Ø ð 	%ð 	%�Ø”:ð 4Ø”z—’ t§~¢~°nÑ'EÔ'EÑFÔFÈÒKÐKØ$ g¨tÐ3Ð3Ð3Ð3Ø”:ð 5Ø”z—’ t§~¢~°nÑ'EÔ'EÑFÔFÈÒKÐKØ$ g¨uÐ4Ð4Ð4Ð4Ø"˜F 5™MœM�	ØÐ(Ø$Ð$Ð$Ð$ð )à�4r*   r   )r&   r[   Úresrg   s   `  @r)   ÚfindFootnotesPlaceholderz*FootnoteExtension.findFootnotesPlaceholder�   s6   øø€ ð	ð 	ð 	ð 	ð 	ð 	ð ˆf�T‰lŒlˆØˆ
r*   Úidra   c                ó   — || j         |<   dS )z' Store a footnote for later retrieval. N©rG   )r&   rj   ra   s      r)   ÚsetFootnotezFootnoteExtension.setFootnote±   s   € à!ˆŒ�rÑÐÐr*   c                óP   — || j         vr| j                              |¦  «         dS dS )z7 Store a footnote reference id in order of appearance. N)rF   Úappend©r&   rj   s     r)   ÚaddFootnoteRefz FootnoteExtension.addFootnoteRefµ   s5   € à�TÔ(Ð(Ð(ØÔ×&Ò& rÑ*Ô*Ð*Ð*Ð*ð )Ð(r*   c                ó,   — |                       d¦  «        S )z Get the footnote separator. r   )r#   rH   s    r)   rP   zFootnoteExtension.get_separatorº   s   € à�~Š~˜kÑ*Ô*Ð*r*   c                óº   — |                       d¦  «        rd|                      ¦   «         | j        |fz  S d                     |                      ¦   «         |¦  «        S )z Return footnote link id. r   z	fn%s%d-%szfn{}{})r#   rP   r   Úformatrp   s     r)   ÚmakeFootnoteIdz FootnoteExtension.makeFootnoteId¾   sW   € à�>Š>˜,Ñ'Ô'ð 	=Ø $×"4Ò"4Ñ"6Ô"6¸Ô8JÈBÐ!OÑOÐOà—?’? 4×#5Ò#5Ñ#7Ô#7¸Ñ<Ô<Ð<r*   c                ó
  — |                       d¦  «        r3|                      d|                      ¦   «         | j        |fz  |¦  «        S |                      d                     |                      ¦   «         |¦  «        |¦  «        S )z Return footnote back-link id. r   zfnref%s%d-%sz	fnref{}{})r#   rZ   rP   r   rt   )r&   rj   rK   s      r)   ÚmakeFootnoteRefIdz#FootnoteExtension.makeFootnoteRefIdÅ   sy   € à�>Š>˜,Ñ'Ô'ð 	XØ—?’? >°T×5GÒ5GÑ5IÔ5IÈ4ÔK]Ð_aÐ4bÑ#bÐdiÑjÔjÐjà—?’? ;×#5Ò#5°d×6HÒ6HÑ6JÔ6JÈBÑ#OÔ#OÐQVÑWÔWÐWr*   úetree.Element | Nonec                óð  — t          | j                             ¦   «         ¦  «        sdS t          j        d¦  «        }|                     dd¦  «         t          j        |d¦  «         t          j        |d¦  «        }t          j        d¦  «        }t          | j                             ¦   «         d¬¦  «        D �]»\  }}t          j        |d	¦  «        }|                     d
|                      |¦  «        ¦  «         | j	         
                    || j        |         ¦  «         t          |¦  «        D ],}|                     |¦  «         |                     |¦  «         Œ-t          j        d¦  «        }	|	                     dd|                      |¦  «        z   ¦  «         |	                     dd¦  «         |	                     d|                      d¦  «                             |¦  «        ¦  «         t           |	_        t%          |¦  «        rh|d         }
|
j        dk    r+|
j        t(          z   |
_        |
                     |	¦  «         �Œ‘t          j        |d¦  «        }|                     |	¦  «         �Œ½|S )z/ Return `div` of footnotes as `etree` Element. NÚdivÚclassr,   ÚhrÚolr   ©ÚstartÚlirj   ÚaÚhrefú#úfootnote-backrefÚtitler   r`   Úp)ÚlistrG   ÚkeysÚetreeÚElementr    Ú
SubElementÚ	enumerateru   r4   Ú
parseChunkro   Úremoverw   r#   rt   ÚFN_BACKLINK_TEXTra   ÚlenÚtagÚNBSP_PLACEHOLDER)r&   r[   rz   r}   Úsurrogate_parentÚindexrj   r€   ÚelÚbacklinkÚnoder†   s               r)   ÚmakeFootnotesDivz"FootnoteExtension.makeFootnotesDivÌ   s<  € õ �D”N×'Ò'Ñ)Ô)Ñ*Ô*ð 	Ø�4åŒm˜EÑ"Ô"ˆØ�Š�˜Ñ$Ô$Ð$ÝÔ˜˜dÑ#Ô#Ð#ÝÔ˜c 4Ñ(Ô(ˆÝ œ=¨Ñ/Ô/Ðå" 4¤>×#6Ò#6Ñ#8Ô#8ÀÐBÑBÔBð 	'ñ 	'‰IˆE�2ÝÔ! " dÑ+Ô+ˆBØ�FŠF�4˜×,Ò,¨RÑ0Ô0Ñ1Ô1Ð1ð ŒK×"Ò"Ð#3°T´^ÀBÔ5GÑHÔHÐHÝÐ+Ñ,Ô,ð ,ð ,�Ø—	’	˜"‘”�Ø ×'Ò'¨Ñ+Ô+Ð+Ð+Ý”} SÑ)Ô)ˆHØ�LŠL˜  t×'=Ò'=¸bÑ'AÔ'AÑ!AÑBÔBÐBØ�LŠL˜Ð"4Ñ5Ô5Ð5Ø�LŠLØØ—’Ð/Ñ0Ô0×7Ò7¸Ñ>Ô>ñô ð õ -ˆHŒMå�2‰wŒwð 'Ø˜"”v�Ø”8˜s’?�?Ø $¤	Õ,<Ñ <�D”IØ—K’K Ñ)Ô)Ð)Ñ)åÔ(¨¨SÑ1Ô1�AØ—H’H˜XÑ&Ô&Ð&ùØˆ
r*   )rC   rD   )F)rI   rJ   rK   rL   rC   rJ   )r[   r\   rC   r]   )rj   rJ   ra   rJ   rC   rD   )rj   rJ   rC   rD   )rC   rJ   )rj   rJ   rC   rJ   )rj   rJ   rK   rL   rC   rJ   )r[   r\   rC   rx   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   rB   r%   rZ   ri   rm   rq   rP   ru   rw   r˜   Ú__classcell__©r(   s   @r)   r   r   '   s  ø€ € € € € ØÐð)ð )ð )ð )ð )ðV)Pð )Pð )PðVð ð ð ðð ð ð ð ð*ð ð ð ð("ð "ð "ð "ð+ð +ð +ð +ð
+ð +ð +ð +ð=ð =ð =ð =ðXð Xð Xð Xð Xð'ð 'ð 'ð 'ð 'ð 'ð 'ð 'r*   r   c                  óp   ‡ — 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}\[\^([^\]]*)\]:[ ]*(.*)$rG   r   c                ób   •— t          ¦   «                              |j        ¦  «         || _        d S ©N)r   r   r4   rG   )r&   rG   r(   s     €r)   r   zFootnoteBlockProcessor.__init__û   s)   ø€ Ý‰Œ×Ò˜Ô)Ñ*Ô*Ð*Ø"ˆŒˆˆr*   Úparentr\   ÚblockrJ   rC   rL   c                ó   — dS )NTr   )r&   r¢   r£   s      r)   ÚtestzFootnoteBlockProcessor.testÿ   s   € Øˆtr*   Úblocksú	list[str]c                ó  — |                      d¦  «        }| j                             |¦  «        }|�r?|                     d¦  «        }|                     d¦  «        g}||                     ¦   «         d…                              d¦  «        }| j                             |¦  «        }|r¦|d|                     ¦   «         …                              d¦  «        }	d                     |d         |  	                    |	¦  «        g¦  «                             d¦  «        |d<   | 
                    d||                     ¦   «         d…         ¦  «         nnd                     |d         |  	                    |¦  «        g¦  «                             d¦  «        |d<   |                     |                      |¦  «        ¦  «         d                     |¦  «        }
| j                             ||
                     ¦   «         ¦  «         |d|                     ¦   «         …                              ¦   «         rC| 
                    d|d|                     ¦   «         …                              d¦  «        ¦  «         dS | 
                    d|¦  «         dS )	z- Find, set, and remove footnote definitions. r   r   r   Nú
z

TF)ÚpopÚREÚsearchrS   ÚendÚlstripr   ÚrstripÚjoinÚdetabÚinsertÚstripÚextendÚdetectTabbedrG   rm   )r&   r¢   r¦   r£   rY   rj   Ú	fn_blocksÚtherestÚm2Úbeforer,   s              r)   ÚrunzFootnoteBlockProcessor.run  s  € à—
’
˜1‘”ˆàŒG�NŠN˜5Ñ!Ô!ˆØñ 	Ø—’˜‘”ˆBØŸš ™œ˜ˆIð ˜AŸEšE™GœG˜H˜H”o×,Ò,¨TÑ2Ô2ˆGØ”—’ Ñ(Ô(ˆBØð <ð !  "§(¢(¡*¤* Ô-×4Ò4°TÑ:Ô:�Ø#Ÿyšy¨)°A¬,¸¿
º
À6Ñ8JÔ8JÐ)KÑLÔL×SÒSÐTXÑYÔY�	˜!‘à—’˜a ¨¯ª©¬¨¨Ô!5Ñ6Ô6Ð6Ð6ð  $Ÿyšy¨)°A¬,¸¿
º
À7Ñ8KÔ8KÐ)LÑMÔM×SÒSÐTXÑYÔY�	˜!‘ð × Ò  ×!2Ò!2°6Ñ!:Ô!:Ñ;Ô;Ð;à—{’{ 9Ñ-Ô-ˆHØŒN×&Ò& r¨8¯?ª?Ñ+<Ô+<Ñ=Ô=Ð=à�Z�a—g’g‘i”i�ZÔ ×&Ò&Ñ(Ô(ð Aà—’˜a  z¨¯ª©	¬	 zÔ!2×!9Ò!9¸$Ñ!?Ô!?Ñ@Ô@Ð@Ø�4à�Š�a˜ÑÔÐØˆur*   c                ó  — g }|�r|d                               d¦  «        râ|                     d¦  «        }| j                             |¦  «        }|rˆ|d|                     ¦   «         …                              d¦  «        }|                     |                      |¦  «        ¦  «         |                     d||                     ¦   «         d…         ¦  «         n-|                     |                      |¦  «        ¦  «         nn|�°|S )z’ Find indented text and remove indent before further processing.

        Returns:
            A list of blocks with indentation removed.
        r   ú    Nr©   )	Ú
startswithrª   r«   r¬   r   r¯   ro   r±   r²   )r&   r¦   r¶   r£   rY   r¹   s         r)   rµ   z#FootnoteBlockProcessor.detectTabbed'  sÿ   € ð ˆ	Øñ 	Ø�aŒy×#Ò# EÑ*Ô*ð ØŸ
š
 1™œ�à”G—N’N 5Ñ)Ô)�Øð 8ð # : A§G¢G¡I¤I :Ô.×5Ò5°dÑ;Ô;�FØ×$Ò$ T§Z¢Z°Ñ%7Ô%7Ñ8Ô8Ð8à—M’M ! U¨1¯7ª7©9¬9¨:¨:Ô%6Ñ7Ô7Ð7àð ×$Ò$ T§Z¢Z°Ñ%6Ô%6Ñ7Ô7Ð7Ð7ð ð' ñ 	ð( Ðr*   c                óÄ   — |                      d¦  «        }t          |¦  «        D ]'\  }}|                     d¦  «        r|dd…         ||<   Œ(d                     |¦  «        S )zˆ Remove one level of indent from a block.

        Preserve lazily indented blocks by only removing indent from indented lines.
        r©   r¼   é   N)rO   rŒ   r½   r°   )r&   r£   ÚlinesÚiÚlines        r)   r±   zFootnoteBlockProcessor.detabD  sh   € ð
 —’˜DÑ!Ô!ˆÝ  Ñ'Ô'ð 	$ð 	$‰GˆAˆtØ�Š˜uÑ%Ô%ð $Ø   œ8��a‘øØ�yŠy˜ÑÔÐr*   ©rG   r   )r¢   r\   r£   rJ   rC   rL   )r¢   r\   r¦   r§   rC   rL   )r¦   r§   rC   r§   )r£   rJ   rC   rJ   )r™   rš   r›   rœ   ÚreÚcompileÚ	MULTILINEr«   r   r¥   rº   rµ   r±   r�   rž   s   @r)   r8   r8   ö   sª   ø€ € € € € Ø>Ð>à	ˆŒÐ8¸"¼,Ñ	GÔ	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. ÚpatternrJ   rG   r   c                óX   •— t          ¦   «                              |¦  «         || _        d S r¡   )r   r   rG   )r&   rÈ   rG   r(   s      €r)   r   z FootnoteInlineProcessor.__init__S  s&   ø€ Ý‰Œ×Ò˜Ñ!Ô!Ð!Ø"ˆŒˆˆr*   rY   úre.Match[str]ÚdatarC   ú3tuple[etree.Element | None, int | None, int | None]c                óœ  — |                      d¦  «        }|| j        j                             ¦   «         v �r•| j                             |¦  «         | j                             d¦  «        s#| j        j                             |¦  «        dz   }nAt          | j        j                             ¦   «         ¦  «                             |¦  «        dz   }t          j	        d¦  «        }t          j
        |d¦  «        }|                     d| j                             |d¬¦  «        ¦  «         |                     dd	| j                             |¦  «        z   ¦  «         |                     d
d¦  «         | j                             d¦  «                             |¦  «        |_        ||                     d¦  «        |                     d¦  «        fS dS )Nr   r   Úsupr�   rj   T)rK   r‚   rƒ   r{   zfootnote-refr   r   )NNN)rS   rG   rˆ   rq   r#   rF   r”   r‡   r‰   rŠ   r‹   r    rw   ru   rt   ra   r   r­   )r&   rY   rË   rj   Úfootnote_numrÎ   r�   s          r)   ÚhandleMatchz#FootnoteInlineProcessor.handleMatchW  s„  € Ø�WŠW�Q‰ZŒZˆØ�”Ô)×.Ò.Ñ0Ô0Ð0Ñ0ØŒN×)Ò)¨"Ñ-Ô-Ð-à”>×+Ò+Ð,BÑCÔCð Sà#œ~Ô<×BÒBÀ2ÑFÔFÈÑJ��õ  $ D¤NÔ$<×$AÒ$AÑ$CÔ$CÑDÔD×JÒJÈ2ÑNÔNÐQRÑR�å”- Ñ&Ô&ˆCÝÔ   cÑ*Ô*ˆAØ�GŠG�D˜$œ.×:Ò:¸2ÀTÐ:ÑJÔJÑKÔKÐKØ�EŠE�&˜# ¤× =Ò =¸bÑ AÔ AÑAÑBÔBÐBØ�EŠE�'˜>Ñ*Ô*Ð*Ø”^×-Ò-Ð.@ÑAÔA×HÒHÈÑVÔVˆAŒFØ˜Ÿš ™
œ
 A§E¢E¨!¡H¤HÐ,Ð,à#Ð#r*   )rÈ   rJ   rG   r   )rY   rÊ   rË   rJ   rC   rÌ   )r™   rš   r›   rœ   r   rÐ   r�   rž   s   @r)   r:   r:   P  sW   ø€ € € € € ØMÐMð#ð #ð #ð #ð #ð #ð$ð $ð $ð $ð $ð $ð $ð $r*   r:   c                  ó:   — e Zd ZdZdd„Zdd„Zdd„Zdd„Zdd„ZdS )r>   z% Amend footnote div with duplicates. rG   r   c                ó   — || _         d S r¡   rl   ©r&   rG   s     r)   r   z"FootnotePostTreeprocessor.__init__q  ó   € Ø"ˆŒˆˆr*   r€   r\   Ú
duplicatesrT   rC   rD   c                óD  — |                      d¦  «        D �]}|j                             dd¦  «        dk    ræ|j        d                              | j                             ¦   «         d¦  «        \  }}g }t          d|dz   ¦  «        D ]c}t          j        |¦  «        }d||| j                             ¦   «         |fz  |j        d<   | 	                    |¦  «         | xj
        dz  c_
        Œdt          |¦  «        d	         }	|D ]}|	 	                    |¦  «         Œ d
S �Œ
d
S )zF Adjust current `li` and add the duplicates: `fnref2`, `fnref3`, etc. r�   r{   Ú r„   r‚   r   r   rN   r`   N)ÚiterÚattribÚgetrO   rG   rP   ÚrangeÚcopyÚdeepcopyro   Úoffsetr‡   )
r&   r€   rÕ   ÚlinkrW   rX   Úlinksr”   Úsib_linkr•   s
             r)   Úadd_duplicatesz(FootnotePostTreeprocessor.add_duplicatest  s,  € à—G’G˜C‘L”Lð 	ñ 	ˆDàŒ{�Š˜w¨Ñ+Ô+Ð/AÒAÐAØ œK¨Ô/×5Ò5°d´n×6RÒ6RÑ6TÔ6TÐVWÑXÔX‘	��Tð �Ý" 1 j°1¡nÑ5Ô5ð %ð %�EÝ#œ}¨TÑ2Ô2�HØ.8¸CÀÈÌ×HdÒHdÑHfÔHfÐhlÐ;mÑ.m�H”O FÑ+Ø—L’L Ñ*Ô*Ð*Ø�K”K 1Ñ$�K”K�Kå˜"‘X”X˜b”\�Ø!ð $ð $�DØ—I’I˜d‘O”O�O�OØ��ñ Bð	ð 	r*   c                ó0  — |j                              dd¦  «                             | j                             ¦   «         d¦  «        \  }}d                     || j                             ¦   «         |¦  «        }| j        j                             |d¦  «        S )z3 Get the number of duplicate refs of the footnote. rj   r×   r   z	{}ref{}{}r   )rÙ   rÚ   rO   rG   rP   rt   r   )r&   r€   ÚfnrX   Úlink_ids        r)   Úget_num_duplicatesz,FootnotePostTreeprocessor.get_num_duplicatesˆ  sz   € à”9—=’=  rÑ*Ô*×0Ò0°´×1MÒ1MÑ1OÔ1OÐQRÑSÔS‰ˆˆDØ×$Ò$ R¨¬×)EÒ)EÑ)GÔ)GÈÑNÔNˆØŒ~Ô(×,Ò,¨W°aÑ8Ô8Ð8r*   r¢   c                óŒ   — t          |¦  «        D ]3}|                      |¦  «        }|dk    r|                      ||¦  «         Œ4dS )z= Find duplicate footnotes and format and add the duplicates. r   N)r‡   ræ   râ   )r&   r¢   r€   Úcounts       r)   Úhandle_duplicatesz+FootnotePostTreeprocessor.handle_duplicatesŽ  sV   € å�v‘,”,ð 	/ð 	/ˆBð ×+Ò+¨BÑ/Ô/ˆEØ�qŠyˆyØ×#Ò# B¨Ñ.Ô.Ð.øð	/ð 	/r*   r[   c                óÜ   — d| _         |                     d¦  «        D ]N}|j                             dd¦  «        dk    r-|                     d¦  «        D ]}|                      |¦  «          ŒOdS )z= Crawl the footnote div and add missing duplicate footnotes. r   rz   r{   r×   r,   r}   N)rÞ   rØ   rÙ   rÚ   ré   )r&   r[   rz   r}   s       r)   rº   zFootnotePostTreeprocessor.run—  s|   € àˆŒØ—9’9˜UÑ#Ô#ð 	ð 	ˆCØŒz�~Š~˜g rÑ*Ô*¨jÒ8Ð8ð Ÿ(š( 4™.œ.ð ð �BØ×*Ò*¨2Ñ.Ô.Ð.Øøð	ð 	r*   NrÃ   )r€   r\   rÕ   rT   rC   rD   )r€   r\   rC   rT   ©r¢   r\   rC   rD   ©r[   r\   rC   rD   )	r™   rš   r›   rœ   r   râ   ræ   ré   rº   r   r*   r)   r>   r>   n  s~   € € € € € Ø/Ð/ð#ð #ð #ð #ðð ð ð ð(9ð 9ð 9ð 9ð/ð /ð /ð /ð	ð 	ð 	ð 	ð 	ð 	r*   r>   c                  ó"   — e Zd ZdZdd„Zdd	„Zd
S )r<   z3 Build and append footnote div to end of document. rG   r   c                ó   — || _         d S r¡   rl   rÓ   s     r)   r   zFootnoteTreeprocessor.__init__¦  rÔ   r*   r[   r\   rC   rD   c                ó–  — | j                              |¦  «        }|�¬| j                              |¦  «        }|ry|\  }}}t          |¦  «                             |¦  «        }|r-|                     |¦  «         |                     ||¦  «         d S |                     |dz   |¦  «         d |_        d S |                     |¦  «         d S d S )Nr   )	rG   r˜   ri   r‡   r”   rŽ   r²   rc   ro   )r&   r[   ÚfootnotesDivÚresultre   r¢   ÚisTextÚinds           r)   rº   zFootnoteTreeprocessor.run©  sÖ   € Ø”~×6Ò6°tÑ<Ô<ˆØÐ#Ø”^×<Ò<¸TÑBÔBˆFØð 
*Ø(.Ñ%��v˜vÝ˜6‘l”l×(Ò(¨Ñ/Ô/�Øð &Ø—M’M %Ñ(Ô(Ð(Ø—M’M # |Ñ4Ô4Ð4Ð4Ð4à—M’M #¨¡'¨<Ñ8Ô8Ð8Ø!%�E”J�J�Jà—’˜LÑ)Ô)Ð)Ð)Ð)ð $Ð#r*   NrÃ   rì   ©r™   rš   r›   rœ   r   rº   r   r*   r)   r<   r<   £  sB   € € € € € Ø=Ð=ð#ð #ð #ð #ð*ð *ð *ð *ð *ð *r*   r<   c                  ó*   — e Zd ZdZdd„Zdd	„Zdd„ZdS )r=   z* Reorder list items in the footnotes div. rG   r   c                ó   — || _         d S r¡   rl   rÓ   s     r)   r   z$FootnoteReorderingProcessor.__init__½  rÔ   r*   r[   r\   rC   rD   c                ó6  — | j         j         sd S | j         j        t          | j         j                              ¦   «         ¦  «        k    rO|                     d¦  «        D ];}|j                             dd¦  «        dk    r|                      |¦  «          d S Œ:d S d S )Nrz   r{   r×   r,   )rG   rF   r‡   rˆ   rØ   rÙ   rÚ   Úreorder_footnotes)r&   r[   rz   s      r)   rº   zFootnoteReorderingProcessor.runÀ  s¦   € ØŒ~Ô'ð 	ØˆFØŒ>Ô(­D°´Ô1I×1NÒ1NÑ1PÔ1PÑ,QÔ,QÒQÐQØ—y’y Ñ'Ô'ð ð �Ø”:—>’> '¨2Ñ.Ô.°*Ò<Ð<Ø×*Ò*¨3Ñ/Ô/Ð/Ø�E�Eð =ð RÐQðð r*   r¢   c                óâ  ‡ — |                      d¦  «        }|                     |¦  «         |                     d¦  «        }dˆ fd„}t          ||¬¦  «        }t	          j        |d¦  «        }t          |d¬¦  «        D ]p\  }}|                      d	¦  «        }|                     d
‰ j         	                    d¦  «         
                    |¦  «        ¦  «         |                     |¦  «         Œqd S )Nr}   r€   rC   rT   c                ó(  •— | j                              dd¦  «                             ‰j                             ¦   «         d¦  «        d         }|‰j        j        v r‰j        j                             |¦  «        nt          ‰j        j        ¦  «        S )Nrj   r×   r   r`   )rÙ   rÚ   rO   rG   rP   rF   r”   r�   )r€   rj   r&   s     €r)   Úorder_by_idzBFootnoteReorderingProcessor.reorder_footnotes.<locals>.order_by_idÎ  s~   ø€ Ø”—’˜t RÑ(Ô(×.Ò.¨t¬~×/KÒ/KÑ/MÔ/MÈqÑQÔQÐRTÔUˆBð ˜œÔ6Ð6Ð6ð ”Ô-×3Ò3°BÑ7Ô7Ð7å˜œÔ1Ñ2Ô2ðr*   )Úkeyr   r~   z.//a[@class="footnote-backref"]r…   r   )rC   rT   )rb   rŽ   ÚfindallÚsortedr‰   r‹   rŒ   r    rG   r#   rt   ro   )	r&   r¢   Úold_listÚitemsrû   Únew_listr”   Úitemr–   s	   `        r)   rø   z-FootnoteReorderingProcessor.reorder_footnotesÉ  s  ø€ Ø—;’;˜tÑ$Ô$ˆØ�Š�hÑÔÐØ× Ò  Ñ&Ô&ˆð	ð 	ð 	ð 	ð 	ð 	õ �u +Ð.Ñ.Ô.ˆåÔ# F¨DÑ1Ô1ˆå$ U°!Ð4Ñ4Ô4ð 	"ð 	"‰KˆE�4Ø—y’yÐ!BÑCÔCˆHØ�LŠL˜ $¤.×":Ò":Ð;KÑ"LÔ"L×"SÒ"SÐTYÑ"ZÔ"ZÑ[Ô[Ð[Ø�OŠO˜DÑ!Ô!Ð!Ð!ð	"ð 	"r*   NrÃ   rì   rë   )r™   rš   r›   rœ   r   rº   rø   r   r*   r)   r=   r=   º  sV   € € € € € Ø4Ð4ð#ð #ð #ð #ðð ð ð ð"ð "ð "ð "ð "ð "r*   r=   c                  ó"   — e Zd ZdZd
d„Zdd„Zd	S )r@   z* Replace placeholders with html entities. rG   r   c                ó   — || _         d S r¡   rl   rÓ   s     r)   r   zFootnotePostprocessor.__init__â  rÔ   r*   ra   rJ   rC   c                óž   — |                      t          | j                             d¦  «        ¦  «        }|                      t          d¦  «        S )Nr   z&#160;)r$   r�   rG   r#   r’   )r&   ra   s     r)   rº   zFootnotePostprocessor.runå  sA   € Ø�|Š|Ý˜dœn×6Ò6°ÑGÔGñ
ô 
ˆð �|Š|Õ,¨hÑ7Ô7Ð7r*   NrÃ   )ra   rJ   rC   rJ   rô   r   r*   r)   r@   r@   à  sB   € € € € € Ø4Ð4ð#ð #ð #ð #ð8ð 8ð 8ð 8ð 8ð 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Å   rQ   ÚRE_REFERENCEr   r8   r:   r>   r<   r=   r@   r  r   r*   r)   ú<module>r     sn  ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø *Ð *Ð *Ð *Ð *Ð *Ø *Ð *Ð *Ð *Ð *Ð *Ø Ð Ð Ð Ð Ð Ø #Ð #Ð #Ð #Ð #Ð #Ø 	€	€	€	Ø €€€Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à”8Ð4Ñ4°t´xÑ?Ð Ø”8Ð4Ñ4°t´xÑ?Ð ØˆBŒJ�Ñ'Ô'€	ØˆrŒzÐ9Ñ:Ô:€ðLð Lð Lð Lð L˜	ñ Lô Lð Lð^W ð W ð W ð W ð W ˜^ñ W ô W ð W ðt$ð $ð $ð $ð $˜oñ $ô $ð $ð<2ð 2ð 2ð 2ð 2 ñ 2ô 2ð 2ðj*ð *ð *ð *ð *˜Mñ *ô *ð *ð.#"ð #"ð #"ð #"ð #" -ñ #"ô #"ð #"ðL	8ð 	8ð 	8ð 	8ð 	8˜Mñ 	8ô 	8ð 	8ð'ð 'ð 'ð 'ð 'r*   