%PDF- %PDF-
Mini Shell

Mini Shell

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

�

���ep����dZddlmZddlmZddlmZmZmZm	Z	ddl
Z
ddlmcm
ZddlmZerddlmZdPd	�Zd
Z	dZ	dZ	d
Z	dZ	dZ	dZ	dZ	dZ	dZ	dZ	dZ	dZ	edzZ 	dZ!	e Z"	e!Z#	dZ$	dZ%	dZ&	dZ'	dZ(	dZ)	dQd�Z*Gd �d!e	�Z+Gd"�d#�Z,Gd$�d%e,�Z-Gd&�d'e,�Z.Gd(�d)e-�Z/Gd*�d+e-�Z0Gd,�d-e,�Z1Gd.�d/e-�Z2Gd0�d1e1�Z3Gd2�d3e2�Z4Gd4�d5e-�Z5Gd6�d7e1�Z6Gd8�d9e2�Z7Gd:�d;e-�Z8Gd<�d=e-�Z9Gd>�d?e9�Z:Gd@�dAe-�Z;GdB�dCe;�Z<GdD�dEe;�Z=GdF�dGe=�Z>GdH�dIe=�Z?GdJ�dKe?�Z@GdL�dMe-�ZAGdN�dOe-�ZBy)RaB
In version 3.0, a new, more flexible inline processor was added, [`markdown.inlinepatterns.InlineProcessor`][].   The
original inline patterns, which inherit from [`markdown.inlinepatterns.Pattern`][] or one of its children are still
supported, though users are encouraged to migrate.

The new `InlineProcessor` provides two major enhancements to `Patterns`:

1. Inline Processors no longer need to match the entire block, so regular expressions no longer need to start with
  `r'^(.*?)'` and end with `r'(.*?)%'`. This runs faster. The returned [`Match`][re.Match] object will only contain
   what is explicitly matched in the pattern, and extension pattern groups now start with `m.group(1)`.

2.  The `handleMatch` method now takes an additional input called `data`, which is the entire block under analysis,
    not just what is matched with the specified pattern. The method now returns the element *and* the indexes relative
    to `data` that the return element is replacing (usually `m.start(0)` and `m.end(0)`).  If the boundaries are
    returned as `None`, it is assumed that the match did not take place, and nothing will be altered in `data`.

    This allows handling of more complex constructs than regular expressions can handle, e.g., matching nested
    brackets, and explicit control of the span "consumed" by the processor.

�)�annotations�)�util)�
TYPE_CHECKING�Any�
Collection�
NamedTupleN)�entities)�Markdownc�6�tj�}|jtt�dd�|jtt|�dd�|jtt|�dd�|jtt|�dd�|jtt|�d	d
�|jtt|�dd�|jtt|�d
d�|jt!t|�dd�|jt#t$|�dd�|jt't(|�dd�|jt+t,d�dd�|jt/t0|�dd�|jt/t2|�dd�|jt5t6�dd�|jt9d�dd �|jt;d!�d"d#�|S)$a
    Build the default set of inline patterns for Markdown.

    The order in which processors and/or patterns are applied is very important - e.g. if we first replace
    `http://.../` links with `<a>` tags and _then_ try to replace inline HTML, we would end up with a mess. So, we
    apply the expressions in the following order:

    * backticks and escaped characters have to be handled before everything else so that we can preempt any markdown
      patterns by escaping them;

    * then we handle the various types of links (auto-links must be handled before inline HTML);

    * then we handle inline HTML.  At this point we will simply replace all inline HTML strings with a placeholder
      and add the actual HTML to a stash;

    * finally we apply strong, emphasis, etc.

    �backtick��escape��	reference��link��
image_link��image_reference��short_reference��short_image_ref�}�autolink�x�automail�n�br�	linebreak�d�html�Z�entity�P�
not_strong�Fz\*�	em_strong�<�_�
em_strong2�2)r�Registry�register�BacktickInlineProcessor�BACKTICK_RE�EscapeInlineProcessor�	ESCAPE_RE�ReferenceInlineProcessor�REFERENCE_RE�LinkInlineProcessor�LINK_RE�ImageInlineProcessor�
IMAGE_LINK_RE�ImageReferenceInlineProcessor�IMAGE_REFERENCE_RE�ShortReferenceInlineProcessor�"ShortImageReferenceInlineProcessor�AutolinkInlineProcessor�AUTOLINK_RE�AutomailInlineProcessor�AUTOMAIL_RE�SubstituteTagInlineProcessor�
LINE_BREAK_RE�HtmlInlineProcessor�HTML_RE�	ENTITY_RE�SimpleTextInlineProcessor�
NOT_STRONG_RE�AsteriskProcessor�UnderscoreProcessor)�md�kwargs�inlinePatternss   �9/usr/lib/python3/dist-packages/markdown/inlinepatterns.py�build_inlinepatternsrP5s���&�]�]�_�N����3�K�@�*�c�R����1�)�R�@�(�C�P����4�\�2�F��UX�Y����/���<�f�c�J����0���C�\�SV�W����%�&8�"�=�?P�RU�����%�l�B�7�9J�C�����*�+=�r�B�DU�WZ�����3�K��D�j�RU�V����3�K��D�j�RU�V����8���M�{�\_�`����/���<�f�b�I����/�	�2�>��"�M����5�m�D�l�TV�W����-�e�4�k�2�F����/��5�|�R�H���z(?<!\!)z;(?:(?<!\\)((?:\\{2})+)(?=`+)|(?<!\\)(`+)(.+?)(?<!`)\2(?!`))z\\(.)z(\*)([^\*]+)\1z(\*{2})(.+?)\1z%(?<!\w)(_{2})(?!_)(.+?)(?<!_)\1(?!\w)z"(?<!\w)(_)(?!_)(.+?)(?<!_)\1(?!\w)z7(?<!\w)(\_)\1(?!\1)(.+?)(?<!\w)\1(?!\1)(.+?)\1{3}(?!\w)z(\*)\1{2}(.+?)\1(.*?)\1{2}z(_)\1{2}(.+?)\1(.*?)\1{2}z(\*)\1{2}(.+?)\1{2}(.*?)\1z(_)\1{2}(.+?)\1{2}(.*?)\1z&(\*)\1(?!\1)([^*]+?)\1(?!\1)(.+?)\1{3}z\[z\!\[z%((^|(?<=\s))(\*{1,3}|_{1,3})(?=\s|$))z+<((?:[Ff]|[Hh][Tt])[Tt][Pp][Ss]?://[^<>]*)>z<([^<> !]+@[^@<> ]+)>z;(<(\/?[a-zA-Z][^<>@ ]*( [^<>]*)?|!--(?:(?!<!--|-->).)*--)>)z-(&(?:\#[0-9]+|\#x[0-9a-fA-F]+|[a-zA-Z0-9]+);)z  \nc��|jd�r|jd�s"|jd�r|jd�r|ddS|S)z#Remove quotes from around a string.�"�'r���)�
startswith�endswith)�strings rO�dequoterY�sE��	�	�	�3�	�F�O�O�C�$8����#��6�?�?�3�#7��a��|���
rQc�0�eZdZUdZded<ded<ded<y)�EmStrongItemzEmphasis/strong pattern item.�re.Pattern[str]�pattern�str�builder�tagsN)�__name__�
__module__�__qualname__�__doc__�__annotations__�rQrOr[r[�s��'�
��
�L�

�IrQr[c�j�eZdZUdZe�Zded<	ded<ded<ddd	�Zdd
�Zdd�Z	dd�Z
dd
�Zy)�Patterna�
    Base class that inline patterns subclass.

    Inline patterns are handled by means of `Pattern` subclasses, one per regular expression.
    Each pattern object uses a single regular expression and must support the following methods:
    [`getCompiledRegExp`][markdown.inlinepatterns.Pattern.getCompiledRegExp] and
    [`handleMatch`][markdown.inlinepatterns.Pattern.handleMatch].

    All the regular expressions used by `Pattern` subclasses must capture the whole block.  For this
    reason, they all start with `^(.*)` and end with `(.*)!`.  When passing a regular expression on
    class initialization, the `^(.*)` and `(.*)!` are added automatically and the regular expression
    is pre-compiled.

    It is strongly suggested that the newer style [`markdown.inlinepatterns.InlineProcessor`][] that
    use a more efficient and flexible search approach be used instead. However, the older style
    `Pattern` remains for backward compatibility with many existing third-party extensions.

    zCollection[str]�ANCESTOR_EXCLUDESr\�compiled_re�Markdown | NonerLNc��||_tjd|ztjtjz�|_||_y)a!
        Create an instant of an inline pattern.

        Arguments:
            pattern: A regular expression that matches a pattern.
            md: An optional pointer to the instance of `markdown.Markdown` and is available as
                `self.md` on the class instance.


        z
^(.*?)%s(.*)$N)r]�re�compile�DOTALL�UNICODErjrL��selfr]rLs   rO�__init__zPattern.__init__�s=������:�:�&6��&@�&(�i�i�"�*�*�&<�>�����rQc��|jS)z' Return a compiled regular expression. )rj�rrs rO�getCompiledRegExpzPattern.getCompiledRegExp�s�����rQc��y)z�Return a ElementTree element from the given match.

        Subclasses should override this method.

        Arguments:
            m: A match object containing a match of the pattern.

        Returns: An ElementTree Element object.

        Nrf�rr�ms  rO�handleMatchzPattern.handleMatch�s��	
rQc�.�|jjS)z+ Return class name, to define pattern type )�	__class__rarus rO�typezPattern.type�s���~�~�&�&�&rQc���	|jjdj��fd�}tj
j
||�S#t$r|cYSwxYw)�> Return unescaped text given text with an inline placeholder. �inlinec���|jd�}|�vrB�j|�}t|t�r|Sdj	|j��Sy)Nr�)�group�get�
isinstancer^�join�itertext)ry�id�value�stashs   �rO�	get_stashz#Pattern.unescape.<locals>.get_stash	sP��������B��U�{��	�	�"�
���e�S�)� �L��7�7�5�>�>�#3�4�4�
rQ�rL�treeprocessors�
stashed_nodes�KeyErrorr�INLINE_PLACEHOLDER_RE�sub�rr�textr�r�s   @rO�unescapezPattern.unescapesX���	��G�G�*�*�8�4�B�B�E�	5��)�)�-�-�i��>�>���	��K�	�s�#A�A�A�N�r]r^rLrk)�returnz
re.Pattern)ry�
re.Match[str]r�zetree.Element | str)r�r^�r�r^r�r^)rarbrcrd�tuplerirersrvrzr}r�rfrQrOrhrh�sB���&*/����0��
!� ����" �
�'�?rQrhc�"�eZdZdZddd�Zdd�Zy)�InlineProcessorz�
    Base class that inline processors subclass.

    This is the newer style inline processor that uses a more
    efficient and flexible search approach.

    Nc��||_tj|tjtjz�|_d|_||_y)a"
        Create an instant of an inline processor.

        Arguments:
            pattern: A regular expression that matches a pattern.
            md: An optional pointer to the instance of `markdown.Markdown` and is available as
                `self.md` on the class instance.

        FN)r]rmrnrorprj�	safe_moderLrqs   rOrszInlineProcessor.__init__s;������:�:�g�r�y�y�2�:�:�/E�F��������rQc��y)a�Return a ElementTree element from the given match and the
        start and end index of the matched text.

        If `start` and/or `end` are returned as `None`, it will be
        assumed that the processor did not find a valid region of text.

        Subclasses should override this method.

        Arguments:
            m: A re match object containing a match of the pattern.
            data: The buffer currently under analysis.

        Returns:
            el: The ElementTree element, text or None.
            start: The start of the region that has been matched or None.
            end: The end of the region that has been matched or None.

        Nrf�rrry�datas   rOrzzInlineProcessor.handleMatch/s��&	
rQr�r�)ryr�r�r^r�z9tuple[etree.Element | str | None, int | None, int | None]�rarbrcrdrsrzrfrQrOr�r�s����"
rQr�c��eZdZdZdd�Zy)�SimpleTextPatternz2 Return a simple text of `group(2)` of a Pattern. c�$�|jd�S)z< Return string content of `group(2)` of a matching pattern. �)r�rxs  rOrzzSimpleTextPattern.handleMatchGs���w�w�q�z�rQN�ryr�r�r^�rarbrcrdrzrfrQrOr�r�Es
��<�rQr�c��eZdZdZdd�Zy)rHz2 Return a simple text of `group(1)` of a Pattern. c�f�|jd�|jd�|jd�fS)z< Return string content of `group(1)` of a matching pattern. rr)r��start�endr�s   rOrzz%SimpleTextInlineProcessor.handleMatchNs'���w�w�q�z�1�7�7�1�:�q�u�u�Q�x�/�/rQN�ryr�r�r^r�ztuple[str, int, int]r�rfrQrOrHrHLs
��<�0rQrHc��eZdZdZdd�Zy)r3z Return an escaped character. c�L�|jd�}||jjvrYdjtj
t
|�tj�|jd�|jd�fSd|jd�|jd�fS)a�
        If the character matched by `group(1)` of a pattern is in [`ESCAPED_CHARS`][markdown.Markdown.ESCAPED_CHARS]
        then return the integer representing the character's Unicode code point (as returned by [`ord`][]) wrapped
        in [`util.STX`][markdown.util.STX] and [`util.ETX`][markdown.util.ETX].

        If the matched character is not in [`ESCAPED_CHARS`][markdown.Markdown.ESCAPED_CHARS], then return `None`.
        r�{}{}{}rN)
r�rL�
ESCAPED_CHARS�formatr�STX�ord�ETXr�r�)rrryr��chars    rOrzz!EscapeInlineProcessor.handleMatchVsw���w�w�q�z���4�7�7�(�(�(��?�?�4�8�8�S��Y����A�1�7�7�1�:�q�u�u�UV�x�W�W�������Q�U�U�1�X�-�-rQN)ryr�r�r^r�ztuple[str | None, int, int]r�rfrQrOr3r3Ss
��(�
.rQr3c� �eZdZdZdd�Zdd�Zy)�SimpleTagPatternz]
    Return element of type `tag` with a text attribute of `group(3)`
    of a Pattern.

    c�>�tj||�||_y)z�
        Create an instant of an simple tag pattern.

        Arguments:
            pattern: A regular expression that matches a pattern.
            tag: Tag of element.

        N)rhrs�tag�rrr]r�s   rOrszSimpleTagPattern.__init__ls��	����w�'����0rQc�p�tj|j�}|jd�|_|S)z�
        Return [`Element`][xml.etree.ElementTree.Element] of type `tag` with the string in `group(3)` of a
        matching pattern as the Element's text.
        �)�etree�Elementr�r�r�)rrry�els   rOrzzSimpleTagPattern.handleMatchys*��
�]�]�4�8�8�
$���'�'�!�*����	rQN�r]r^r�r^�ryr�r��
etree.Elementr�rfrQrOr�r�fs���
1�rQr�c� �eZdZdZdd�Zdd�Zy)�SimpleTagInlineProcessorz]
    Return element of type `tag` with a text attribute of `group(2)`
    of a Pattern.

    c�>�tj||�||_y)z�
        Create an instant of an simple tag processor.

        Arguments:
            pattern: A regular expression that matches a pattern.
            tag: Tag of element.

        N)r�rsr�r�s   rOrsz!SimpleTagInlineProcessor.__init__�s��	� � ��w�/����0rQc��tj|j�}|jd�|_||jd�|j
d�fS)z�
        Return [`Element`][xml.etree.ElementTree.Element] of type `tag` with the string in `group(2)` of a
        matching pattern as the Element's text.
        r�r)r�r�r�r�r�r�r��rrryr�r�s    rOrzz$SimpleTagInlineProcessor.handleMatch�sB��
�]�]�4�8�8�
$���'�'�!�*����1�7�7�1�:�q�u�u�Q�x�'�'rQNr��ryr�r�r^r�ztuple[etree.Element, int, int]r�rfrQrOr�r��s���
1�(rQr�c��eZdZdZdd�Zy)�SubstituteTagPattern�3 Return an element of type `tag` with no children. c�@�tj|j�S)�H Return empty [`Element`][xml.etree.ElementTree.Element] of type `tag`. )r�r�r�rxs  rOrzz SubstituteTagPattern.handleMatch�s���}�}�T�X�X�&�&rQNr�r�rfrQrOr�r��s
��=�'rQr�c��eZdZdZdd�Zy)rCr�c��tj|j�|jd�|j	d�fS)r�r)r�r�r�r�r�r�s   rOrzz(SubstituteTagInlineProcessor.handleMatch�s,���}�}�T�X�X�&�����
�A�E�E�!�H�<�<rQNr�r�rfrQrOrCrC�s
��=�=rQrCc� �eZdZdZdd�Zdd�Zy)r1zA Return a `<code>` element containing the escaped matching text. c��tj||�djtjtd�tj�|_d|_y)Nr��\�code)	r�rsr�rr�r�r��ESCAPED_BSLASHr�)rrr]s  rOrsz BacktickInlineProcessor.__init__�s=��� � ��w�/�&�o�o�d�h�h��D�	�4�8�8�L������0rQc���|jd�r�tj|j�}t	j
t	j|jd�j���|_||jd�|jd�fS|jd�jd|j�|jd�|jd�fS)a�
        If the match contains `group(3)` of a pattern, then return a `code`
        [`Element`][xml.etree.ElementTree.Element] which contains HTML escaped text (with
        [`code_escape`][markdown.util.code_escape]) as an [`AtomicString`][markdown.util.AtomicString].

        If the match does not contain `group(3)` then return the text of `group(1)` backslash escaped.

        r�rrz\\)
r�r�r�r�r�AtomicString�code_escape�stripr�r�r��replacer�r�s    rOrzz#BacktickInlineProcessor.handleMatch�s���
�7�7�1�:����t�x�x�(�B��'�'��(8�(8������9I�9I�9K�(L�M�B�G��q�w�w�q�z�1�5�5��8�+�+��7�7�1�:�%�%�f�d�.A�.A�B�A�G�G�A�J�PQ�PU�PU�VW�PX�X�XrQN)r]r^)ryr�r�r^r�z$tuple[etree.Element | str, int, int]r�rfrQrOr1r1�s��K�1�YrQr1c��eZdZdZdd�Zy)�DoubleTagPattern�fReturn a ElementTree element nested in tag2 nested in tag1.

    Useful for strong emphasis etc.

    c�(�|jjd�\}}tj|�}tj||�}|jd�|_t|j��dk(r|jd�|_	|S)z�
        Return [`Element`][xml.etree.ElementTree.Element] in following format:
        `<tag1><tag2>group(3)</tag2>group(4)</tag2>` where `group(4)` is optional.

        �,r���)
r��splitr�r��
SubElementr�r��len�groups�tail)rrry�tag1�tag2�el1�el2s      rOrzzDoubleTagPattern.handleMatch�so���X�X�^�^�C�(�
��d��m�m�D�!�����s�D�)���7�7�1�:����q�x�x�z�?�a���w�w�q�z�C�H��
rQNr�r�rfrQrOr�r��s���
rQr�c��eZdZdZdd�Zy)�DoubleTagInlineProcessorr�c�j�|jjd�\}}tj|�}tj||�}|jd�|_t|j��dk(r|jd�|_	||jd�|jd�fS)z�
        Return [`Element`][xml.etree.ElementTree.Element] in following format:
        `<tag1><tag2>group(2)</tag2>group(3)</tag2>` where `group(3)` is optional.

        r�r�r�r)r�r�r�r�r�r�r�r�r�r�r�r�)rrryr�r�r�r�r�s       rOrzz$DoubleTagInlineProcessor.handleMatch�s����X�X�^�^�C�(�
��d��m�m�D�!�����s�D�)���7�7�1�:����q�x�x�z�?�a���w�w�q�z�C�H��A�G�G�A�J����a��(�(rQNr�r�rfrQrOr�r��s���
)rQr�c�(�eZdZdZdd�Zdd�Zdd�Zy)rEz1 Store raw inline html and return a placeholder. c���|j|j|jd���}|jjj|�}||j
d�|jd�fS)zL Store the text of `group(1)` of a pattern and return a placeholder string. rr)�backslash_unescaper�r�rL�	htmlStash�storer�r�)rrryr��rawhtml�place_holders     rOrzzHtmlInlineProcessor.handleMatch�sZ���)�)�$�-�-�����
�*C�D���w�w�(�(�.�.�w�7���Q�W�W�Q�Z����q��1�1rQc����	�jjdj�d��fd�}tj
j
||�S#t$r|cYSwxYw)rr�c���|jd�}�j|�}|�	�jj|�Sy#t$rd|zcYSwxYw)Nrz\%s)r�r�rL�
serializer�	Exception)ryr�r�rrr�s   ��rOr�z/HtmlInlineProcessor.unescape.<locals>.get_stashs]��������B��I�I�b�M�E�� �*��7�7�-�-�e�4�4�!��!�*�!�E�>�)�*�s�A�A�Ar�r�r�s`  @rOr�zHtmlInlineProcessor.unescape�sX���	��G�G�*�*�8�4�B�B�E�	*��)�)�-�-�i��>�>���	��K�	�s�#A�A�Ac��	|jjdj}dd�}|j	||�S#t$r|cYSwxYw)zG Return text with backslash escapes undone (backslashes are restored). r�c�H�tt|jd���S)Nr)�chr�intr�)rys rO�	_unescapez9HtmlInlineProcessor.backslash_unescape.<locals>._unescapes���s�1�7�7�1�:��'�'rQr�)rLr��REr�r�)rrr�r�r�s    rOr�z&HtmlInlineProcessor.backslash_unescapesO��	����'�'�
�3�6�6�B�	(��v�v�i��&�&��
�	��K�	�s�#;�A	�A	Nr�r�)rarbrcrdrzr�r�rfrQrOrErE�s��;�2�?�$
'rQrEc�D�eZdZdZeejeejejz�dd�eeje
ejejz�dd�eejeejejz�dd�eejeejejz�dd�eeje
ejejz�dd�gZ	dd	�Zdd
�Zdd�Z										dd�Zdd
�Zdd�Zy)rJzGEmphasis processor for handling strong and em matches inside asterisks.�double�	strong,em�	em,strong�double2�single�strong�emc�z�tj|�}|jd�}|j||d|�|S)zReturn single tag.r�N)r�r�r��parse_sub_patterns)rrryr��idxr�r�s      rO�build_singlezAsteriskProcessor.build_single$s6���m�m�C� ���w�w�q�z������c�4��5��
rQc�p�|jd�\}}tj|�}tj|�}|jd�}|j	||d|�|j|�t
|j��dk(r%|jd�}|j	||||�|S)zReturn double tag.r�r�Nr�)r�r�r�r�r�appendr�r��	rrryr`r	r�r�r�r�r�s	         rO�build_doublezAsteriskProcessor.build_double+s����Z�Z��_�
��d��m�m�D�!���m�m�D�!���w�w�q�z������c�4��5��
�
�3���q�x�x�z�?�a���7�7�1�:�D��#�#�D�#�s�C�8��
rQc�8�|jd�\}}tj|�}tj|�}|jd�}|j	||d|�|jd�}|j|�|j	||d|�|S)zFReturn double tags (variant 2): `<strong>text <em>text</em></strong>`.r�r�Nr�)r�r�r�r�rrr
s	         rO�
build_double2zAsteriskProcessor.build_double29s����Z�Z��_�
��d��m�m�D�!���m�m�D�!���w�w�q�z������c�4��5��w�w�q�z���
�
�3������c�4��5��
rQc�2�d}d}t|�}||kr�|jj||�r�d}t|j�D]�\}	}
|	|kr�|
j
j||�}|s�+|||j
d�}|r|�||_n||_|j||
j|
j|	�}
|j|
�|
}|jd�x}}d}��|s|dz
}n|dz
}||kr��||d}|r|�||_y||_yy)a/
        Parses sub patterns.

        `data`: text to evaluate.

        `parent`: Parent to attach text and sub elements to.

        `last`: Last appended child to parent. Can also be None if parent has no children.

        `idx`: Current pattern index that was used to evaluate the parent.
        rFNTr)r�rj�match�	enumerate�PATTERNSr]r�r�r��
build_elementr_r`rr�)rrr��parent�lastr	�offset�pos�length�matched�index�itemryr�r�s              rOrz$AsteriskProcessor.parse_sub_patternsFs8�������T����F�l����%�%�d�C�0���#,�T�]�]�#;�'�K�E�4���|� ����*�*�4��5�A��
 $�F�1�7�7�1�:�6���#�/�,0��	�.2���!�/�/��4�<�<����E�R���
�
�b�)�!��'(�u�u�Q�x�/���"&��+'�,��1�H�C��q���A�F�l�F�F�G�}����� ��	�"���	rQc��|dk(r|j|||�S|dk(r|j|||�S|j|||�S)zElement builder.rr)rrr
)rrryr_r`rs     rOrzAsteriskProcessor.build_element�sS���i���%�%�a��u�5�5�
��
 ��$�$�Q��e�4�4��$�$�Q��e�4�4rQc�D�d}d}d}t|j�D]~\}}|jj||j	d��}|s�4|j	d�}|jd�}|j
||j|j|�}n|||fS)zParse patterns.Nr)	rrr]rr�r�rr_r`)	rrryr�r�r�r�rr�m1s	         rOrzzAsteriskProcessor.handleMatch�s���������$�T�]�]�3�	�K�E�4����#�#�D�!�'�'�!�*�5�B���������f�f�Q�i���'�'��D�L�L�$�)�)�U�K���
	��5�#�~�rQN)ryr�r�r^r	r�r�r�)ryr�r`r^r	r�r�r�)
r�r^rr�rzetree.Element | Noner	r�r��None)
ryr�r_r^r`r^rr�r�r��ryr�r�r^r�z3tuple[etree.Element | None, int | None, int | None])rarbrcrdr[rmrn�EM_STRONG_RErorp�STRONG_EM_RE�
STRONG_EM3_RE�	STRONG_RE�EMPHASIS_RErr
rrrrrzrfrQrOrJrJs��Q�	�Z�R�Z�Z��b�i�i�"�*�*�.D�E�x�Q\�]��Z�R�Z�Z��b�i�i�"�*�*�.D�E�x�Q\�]��Z�R�Z�Z�
�r�y�y�2�:�:�/E�F�	�S^�_��Z�R�Z�Z�	�2�9�9�r�z�z�+A�B�H�h�W��Z�R�Z�Z��R�Y�Y����-C�D�h�PT�U��H�P����;#��;#�!.�;#�6J�;#�QT�;#�	
�;#�z5�rQrJc��eZdZdZeejeejejz�dd�eeje
ejejz�dd�eejeejejz�dd�eejeejejz�dd�eeje
ejejz�dd�gZy	)
rKzIEmphasis processor for handling strong and em matches inside underscores.rrrrrrrN)rarbrcrdr[rmrn�
EM_STRONG2_RErorp�
STRONG_EM2_RE�SMART_STRONG_EM_RE�SMART_STRONG_RE�SMART_EMPHASIS_RErrfrQrOrKrK�s���S�	�Z�R�Z�Z�
�r�y�y�2�:�:�/E�F��R]�^��Z�R�Z�Z�
�r�y�y�2�:�:�/E�F��R]�^��Z�R�Z�Z� 2�B�I�I��
�
�4J�K�Y�Xc�d��Z�R�Z�Z�����R�Z�Z�1G�H�(�T\�]��Z�R�Z�Z� 1�2�9�9�r�z�z�3I�J�H�VZ�[��H�PrQrKc��eZdZdZej
dejejz�Zej
d�Z	dd�Z
d	d�Zd
d�Zy)r7z- Return a link element from the given match. z2\(\s*(?:(<[^<>]*>)\s*(?:('[^']*'|"[^"]*")\s*)?\))?z\sc�2�|j||jd��\}}}|sy|j||�\}}}}|sytjd�}||_|j
d|�|�|j
d|�||jd�|fS)zS Return an `a` [`Element`][xml.etree.ElementTree.Element] or `(None, None, None)`. r�NNN�a�href�title)�getTextr��getLinkr�r�r��setr�)	rrryr�r�r�handledr2r3r�s	         rOrzzLinkInlineProcessor.handleMatch�s���#�|�|�D�!�%�%��(�;���e�W��#�&*�l�l�4��&?�#��e�U�G��#�
�]�]�3�
�����
���v�t�����F�F�7�E�"��1�7�7�1�:�u�$�$rQc	��d}d}d}|jj||��}|rm|jd�r\|jd�ddj�}|jd�r|jd�dd}|j	d�}d	}�nc|�r`d}d}|j	�}	|	}d}
d}d}d}
d}d}d}d}d}t|t
|��D�]}||}|d
k(r|s|dz
}n~|dkDry|dz}ns|dk(r4|
dk7r||k(s
|dk7r||k(rd}nW|s|dz}nO|dkDrJ|dz}|dk(r@|dz}
n:|dvr6|sd	}|}d}|dz}|}n&||k7r
|s|dz}|}n||k(r|dz}
n|r
||k(r|dz}|dz
}|dk(r^|
dk\r%||k(r ||	|dz
}dj|||
dz
�}n2|dk\r%||k(r ||	|dz
}dj|||dz
�}n||	|dz
}n|d
k7s��|}��|dk7r|dk(r||	|
dz
}|
}d}|dk(}|�B|jjd
t|j|j����}|j|�j�}||||fS)z?Parse data between `()` of `[Text]()` allowing recursive `()`. r�NF�rrrUr�rT�(�))rTrS� )�RE_LINKrr�r�r��ranger�r��RE_TITLE_CLEANr�rYr�)rrr�rr2r3r7ry�
bracket_count�backtrack_count�start_index�last_bracket�quote�start_quote�
exit_quote�ignore_matches�	alt_quote�start_alt_quote�exit_alt_quoterr�cs                     rOr5zLinkInlineProcessor.getLink�s���� �����L�L���t���/���������7�7�1�:�a��#�)�)�+�D��w�w�q�z�����
�1�R�(���E�E�!�H�E��G�
��M��O��%�%�'�K��E��L�!%�E��K��J�"�N��I� �O��N��D��U�C��I�.�;
����I����8�*�%��*�
�(�1�,�'�1�,���#�X�$�r�)�e�t�m��SU�AU�Zc�gk�Zk�()�
�+�%��*�
�(�1�,�'�1�,��*�a�/�+0�1�9�L��*�_� �*.��*7��()�
�&+�a�i�� !���e��I�*/�!�)��$%�	��e��%*�Q�Y�
�"�q�I�~�).������
��!�A�%�!�Q��5�D�=�#�K��a��@�� "����[��a��(H� I��'�1�,��d�1B�#�K��!�0C�D�� "����_�^�a�=O�(P� Q��#�K���	�:�����8��D�w;
�B��!�o��&:��K��q�(8�9��$�� !�
�#�q�(�G����'�'�+�+�C�����u�{�{�}�9U�1V�W�E��}�}�T�"�(�(�*���U�E�7�*�*rQc���d}g}t|t|��D]9}||}|dk(r|dz}n
|dk(r|dz
}|dz
}|dk(rn|j|��;dj|�||dk(fS)zsParse the content between `[]` of the start of an image or link
        resolving nested square brackets.

        r�]�[rr�)r>r�rr�)rrr�rr@r�rrKs       rOr4zLinkInlineProcessor.getText9s���
�
������D�	�*�		�C��S�	�A��C�x���"�
��c����"�
��Q�J�E���!���K�K��N�		��w�w�t�}�e�]�a�%7�7�7rQNr")r�r^rr�r�z!tuple[str, str | None, int, bool])r�r^rr�r��tuple[str, int, bool])
rarbrcrdrmrnrorpr=r?rzr5r4rfrQrOr7r7�sL��7��b�j�j�R�TV�T]�T]�`b�`j�`j�Tj�k�G��R�Z�Z��&�N�%�*r+�h8rQr7c��eZdZdZdd�Zy)r9z. Return a `img` element from the given match. c�f�|j||jd��\}}}|sy|j||�\}}}}|sytjd�}|jd|�|�|jd|�|jd|j
|��||jd�|fS)zU Return an `img` [`Element`][xml.etree.ElementTree.Element] or `(None, None, None)`. rr0�img�srcr3�alt)r4r�r5r�r�r6r�r�)	rrryr�r�rr7rSr3r�s	         rOrzz ImageInlineProcessor.handleMatchPs���#�|�|�D�!�%�%��(�;���e�W��#�%)�\�\�$��%>�"��U�E�7��#�
�]�]�5�
!��
���u�c�����F�F�7�E�"�
���u�d�m�m�D�)�*��1�7�7�1�:�u�$�$rQNr"r�rfrQrOr9r9Ms
��8�%rQr9c��eZdZdZej
dej�Zej
dejejz�Z
dd�Zd	d�Zd
d�Z
y)r5z6 Match to a stored reference and return link element. z\s+z\s?\[([^\]]*)\]c��|j||jd��\}}}|sy|j|||�\}}}|sy|jj	d|�}||j
jvrd|jd�|fS|j
j|\}}	|j||	|�|jd�|fS)zz
        Return [`Element`][xml.etree.ElementTree.Element] returned by `makeTag` method or `(None, None, None)`.

        rr0r<N)	r4r��evalId�NEWLINE_CLEANUP_REr�rL�
referencesr��makeTag)
rrryr�r�rr7r�r�r2r3s
          rOrzz$ReferenceInlineProcessor.handleMatchks���
 $�|�|�D�!�%�%��(�;���e�W��#��;�;�t�U�D�9���C���#��
$�
$�
(�
(��b�
1��
�T�W�W�'�'�'�������S�(�(��g�g�(�(��,���e��|�|�D�%��.�����
�C�?�?rQc���|jj||��}|sd|dfS|jd�j�}|j	d�}|s|j�}||dfS)z\
        Evaluate the id portion of `[ref][id]`.

        If `[ref][]` use `[ref]`.
        r9NFrrT)r=rr��lowerr�)rrr�rr�ryr�r�s       rOrWzReferenceInlineProcessor.evalId�sj��
�L�L���t���/������%�%������!�!�#�B��%�%��(�C���Z�Z�\���3��}�rQc��tjd�}|jd|�|r|jd|�||_|S)z; Return an `a` [`Element`][xml.etree.ElementTree.Element]. r1r2r3)r�r�r6r��rrr2r3r�r�s     rOrZz ReferenceInlineProcessor.makeTag�s;��
�]�]�3�
��
���v�t����F�F�7�E�"�����	rQNr")r�r^rr�r�r^r�ztuple[str | None, int, bool]�r2r^r3r^r�r^r�r�)rarbrcrdrmrn�	MULTILINErXrorpr=rzrWrZrfrQrOr5r5esL��@�#����F�B�L�L�9���b�j�j�+�R�Y�Y����-C�D�G�@�,� 	rQr5c��eZdZdZdd�Zy)r=z%Short form of reference: `[google]`. c�(�|j�|dfS�zEvaluate the id of `[ref]`.  T�r\�rrr�rr�s    rOrWz$ShortReferenceInlineProcessor.evalId�����z�z�|�U�D�(�(rQN�r�r^rr�r�r^r�rO�rarbrcrdrWrfrQrOr=r=�s
��/�)rQr=c��eZdZdZdd�Zy)r;z7 Match to a stored reference and return `img` element. c��tjd�}|jd|�|r|jd|�|jd|j|��|S)z= Return an `img` [`Element`][xml.etree.ElementTree.Element]. rRrSr3rT)r�r�r6r�r^s     rOrZz%ImageReferenceInlineProcessor.makeTag�sK��
�]�]�5�
!��
���u�d����F�F�7�E�"�
���u�d�m�m�D�)�*��	rQNr_)rarbrcrdrZrfrQrOr;r;�s
��A�rQr;c��eZdZdZdd�Zy)r>z* Short form of image reference: `![ref]`. c�(�|j�|dfSrcrdres    rOrWz)ShortImageReferenceInlineProcessor.evalId�rfrQNrgrhrfrQrOr>r>�s
��4�)rQr>c��eZdZdZdd�Zy)r?zD Return a link Element given an auto-link (`<http://example/com>`). c�$�tjd�}|jd|j|j	d���tj|j	d��|_||jd�|jd�fS)zI Return an `a` [`Element`][xml.etree.ElementTree.Element] of `group(1)`. r1r2rr)
r�r�r6r�r�rr�r�r�r�r�s    rOrzz#AutolinkInlineProcessor.handleMatch�sf��
�]�]�3�
��
���v�t�}�}�Q�W�W�Q�Z�0�1��#�#�A�G�G�A�J�/����1�7�7�1�:�q�u�u�Q�x�'�'rQNr�r�rfrQrOr?r?�s
��N�(rQr?c��eZdZdZdd�Zy)rAzW
    Return a `mailto` link Element given an auto-mail link (`<foo@example.com>`).
    c
�@�tjd�}|j|jd��}|j	d�r|td�d}d
d�}|D�cgc]}|t
|����}}tjdj|��|_
d|z}dj|D�cgc]!}tjdt
|�zz��#c}�}|jd|�||jd	�|jd	�fScc}wcc}w)za Return an [`Element`][xml.etree.ElementTree.Element] containing a `mailto` link  of `group(1)`. r1rzmailto:Nc��tjj|�}|r djtj
|�Sdtj
|fzS)z=Return entity definition by code, or the code if not defined.z{}{};z%s#%d;)r
�codepoint2namer�r�r�AMP_SUBSTITUTE)r�r&s  rOrrz;AutomailInlineProcessor.handleMatch.<locals>.codepoint2name�sH���,�,�0�0��6�F���~�~�d�&9�&9�6�B�B��4�#6�#6��"=�=�=rQr�z#%d;r2r)r�r�r�r^)r�r�r�r�rVr�r�rr�r�r�rsr6r�r�)	rrryr�r��emailrr�letter�letters�mailtos	         rOrzz#AutomailInlineProcessor.handleMatch�s��
�]�]�3�
���
�
�a�g�g�a�j�)�����I�&��#�i�.�/�*�E�	>�>C�C�6�>�#�f�+�.�C��C��#�#�B�G�G�G�$4�5����U�"�����4:�<�*0��-�-���f�+�1&�&�<�=��
���v�v���1�7�7�1�:�q�u�u�Q�x�'�'��D��<s�D�4&DNr�r�rfrQrOrArA�s���(rQrA)rLrrMrr�zutil.Registry[InlineProcessor])rXr^r�r^)Crd�
__future__rr�r�typingrrrr	rm�xml.etree.ElementTreer��ElementTreer$r
�markdownrrP�NOIMGr2r4r'r&r,r-r+r#r)r$r*r%r8r:r6r<rIr@rBrFrGrDrYr[rhr�r�rHr3r�r�r�rCr1r�r�rErJrKr7r9r5r=r;r>r?rArfrQrO�<module>r~s.��(�*#��=�=�	�%�%���!�*�`	��\�L��M��	�=���7��	�5�:��b�9��c�O��B�,��S�,�
�V�,��?�,�
�B�9�
�?�
�%�-��`��
�S���5�"��:�8�
�'�<��=�&��;�
H��$�<�	�V��
�(���:��S?�S?�l-
�g�-
�`���0��0�.�O�.�&�w��:(��(�:'�+�'�=�#;�=�Y�o�Y�2�'��*)�7�)�*$'�/�$'�NC��C�L
P�+�
P�_8�/�_8�D%�.�%�05�2�5�p)�$<�)�	�$<�	�)�)F�)�(�o�(�(�o�(rQ

Zerion Mini Shell 1.0