U
    muf                     @   s   d dl Z ddlmZ dddddgZe d	e d
 Ze d	e d Ze d	e d Zde d Zde d Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d Zd*d Zd+d Zd,d Zd-d ZdS ).    N   )PREVENT_BACKSLASHstrikethroughmarkinsertsuperscript	subscriptz(?:z\\~|[^\s~])~~(?!~)z\\=|[^\s=])==(?!=)z\\\^|[^\s^])\^\^(?!\^)z\^(?:z\\\^|\S|\\ )+?\^z~(?:z\\~|\S|\\ )+?~c                 C   s   t | ||dtS )Nr   )_parse_to_end_STRIKE_ENDinlinemstate r   >/tmp/pip-unpacked-wheel-8p1ovdot/mistune/plugins/formatting.pyparse_strikethrough   s    r   c                 C   s   d| d S )Nz<del>z</del>r   renderertextr   r   r   render_strikethrough   s    r   c                 C   s   t | ||dtS )Nr   )r	   	_MARK_ENDr   r   r   r   
parse_mark   s    r   c                 C   s   d| d S )Nz<mark>z</mark>r   r   r   r   r   render_mark   s    r   c                 C   s   t | ||dtS )Nr   )r	   _INSERT_ENDr   r   r   r   parse_insert   s    r   c                 C   s   d| d S )Nz<ins>z</ins>r   r   r   r   r   render_insert"   s    r   c                 C   s   t | ||dS )Nr   _parse_scriptr   r   r   r   parse_superscript&   s    r   c                 C   s   d| d S )Nz<sup>z</sup>r   r   r   r   r   render_superscript*   s    r   c                 C   s   t | ||dS )Nr   r   r   r   r   r   parse_subscript.   s    r    c                 C   s   d| d S )Nz<sub>z</sub>r   r   r   r   r   render_subscript2   s    r!   c                 C   sd   |  }||j|}|sd S |  }|j||d  }| }	||	_| |	}
|||
d |S )Nr   typechildren)endsearchsrccopyrenderappend_token)r   r   r   tok_typeZend_patternposm1Zend_posr   	new_stater$   r   r   r   r	   6   s    
r	   c                 C   sJ   | d}| }|dd dd|_| |}|||d | S )Nr      z\  r"   )groupr(   replacer'   r)   r*   r%   )r   r   r   r+   r   r.   r$   r   r   r   r   D   s    

r   c                 C   s8   | j jddtdd | jr4| jjdkr4| jdt dS )aI  A mistune plugin to support strikethrough. Spec defined by
    GitHub flavored Markdown and commonly used by many parsers:

    .. code-block:: text

        ~~This was mistaken text~~

    It will be converted into HTML:

    .. code-block:: html

        <del>This was mistaken text</del>

    :param md: Markdown instance
    r   z~~(?=[^\s~])linkbeforehtmlN)r   registerr   r   NAMEr   Zmdr   r   r   r   P   s    c                 C   s8   | j jddtdd | jr4| jjdkr4| jdt dS )zA mistune plugin to add ``<mark>`` tag. Spec defined at
    https://facelessuser.github.io/pymdown-extensions/extensions/mark/:

    .. code-block:: text

        ==mark me== ==mark \=\= equal==

    :param md: Markdown instance
    r   z==(?=[^\s=])r4   r5   r7   N)r   r8   r   r   r9   r   r:   r   r   r   r   j   s    
c                 C   s8   | j jddtdd | jr4| jjdkr4| jdt dS )zA mistune plugin to add ``<ins>`` tag. Spec defined at
    https://facelessuser.github.io/pymdown-extensions/extensions/caret/#insert:

    .. code-block:: text

        ^^insert me^^

    :param md: Markdown instance
    r   z\^\^(?=[^\s\^])r4   r5   r7   N)r   r8   r   r   r9   r   r:   r   r   r   r   ~   s    
c                 C   s8   | j jdttdd | jr4| jjdkr4| jdt dS )zA mistune plugin to add ``<sup>`` tag. Spec defined at
    https://pandoc.org/MANUAL.html#superscripts-and-subscripts:

    .. code-block:: text

        2^10^ is 1024.

    :param md: Markdown instance
    r   	linebreakr5   r7   N)r   r8   SUPERSCRIPT_PATTERNr   r   r9   r   r:   r   r   r   r      s    
c                 C   s8   | j jdttdd | jr4| jjdkr4| jdt dS )zA mistune plugin to add ``<sub>`` tag. Spec defined at
    https://pandoc.org/MANUAL.html#superscripts-and-subscripts:

    .. code-block:: text

        H~2~O is a liquid.

    :param md: Markdown instance
    r   r;   r5   r7   N)r   r8   SUBSCRIPT_PATTERNr    r   r9   r!   r:   r   r   r   r      s    
)reZhelpersr   __all__compiler
   r   r   r<   r=   r   r   r   r   r   r   r   r   r    r!   r	   r   r   r   r   r   r   r   r   r   r   <module>   s0   