U
    muf                     @   s   d dl Z ddlmZ dgZdZe ee jZe de jZe de jZ	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S )    N   )	strip_enddef_listzp^(?P<def_list_head>(?:[^\n]+\n)+?)\n?(?:\:[ \t]+.*\n(?:[^\n]+\n)*(?:(?:[ \t]*\n)*[ \t]+[^\n]+\n)*(?:[ \t]*\n)*)+z^:[ \t]+z^ {0,4}z\n[ \t]*\n$c                 C   sh   |  }tt| |}t|j|}|rT|tt| | |  }t|j|}q$|d|d |S )Nr   typechildren)endlist_parse_def_itemDEF_REmatchsrcextendZappend_token)blockmstateposr    r   </tmp/pip-unpacked-wheel-8p1ovdot/mistune/plugins/def_list.pyparse_def_list   s    r   c           
      c   s   | d}| D ]}d|dV  q| d}t|}t||}| }||| dk}|rt||d }|stq| }||| ddd}t| ||}	tt	|}d|	d	V  |}qZ||d  ddd}t| ||}	d|	d	V  d S )
Ndef_list_head)r   textr   
   : def_list_itemr   )
group
splitlineslenDD_START_REsearchstartreplace_process_textboolHAS_BLANK_LINE_RE)
r   r   headliner   r   r"   Zprev_blank_liner   r   r   r   r   r
   (   s6    


r
   c                 C   sf   t d|}|  }|t| | || j |j}|sbt|dkrb|d d dkrbd|d d< |S )N r   r   r   	paragraphZ
block_text)	TRIM_REsubZ	state_clsprocessr   parseZ
list_rulestokensr   )r   r   looser   r/   r   r   r   r$   M   s     r$   c                 C   s   d| d S )Nz<dl>
z</dl>
r   rendererr   r   r   r   render_def_listY   s    r3   c                 C   s   d| d S )Nz<dt>z</dt>
r   r1   r   r   r   render_def_list_head]   s    r4   c                 C   s   d| d S )Nz<dd>z</dd>
r   r1   r   r   r   render_def_list_itema   s    r5   c                 C   sT   | j jdttdd | jrP| jjdkrP| jdt | jdt | jdt dS )a  A mistune plugin to support def list, spec defined at
    https://michelf.ca/projects/php-markdown/extra/#def-list

    Here is an example:

    .. code-block:: text

        Apple
        :   Pomaceous fruit of plants of the genus Malus in
            the family Rosaceae.

        Orange
        :   The fruit of an evergreen tree of the genus Citrus.

    It will be converted into HTML:

    .. code-block:: html

        <dl>
        <dt>Apple</dt>
        <dd>Pomaceous fruit of plants of the genus Malus in
        the family Rosaceae.</dd>

        <dt>Orange</dt>
        <dd>The fruit of an evergreen tree of the genus Citrus.</dd>
        </dl>

    :param md: Markdown instance
    r   r*   )beforehtmlr   r   N)	r   registerDEF_PATTERNr   r2   NAMEr3   r4   r5   )Zmdr   r   r   r   e   s
    )reutilr   __all__r9   compileMr   r    r+   r&   r   r
   r$   r3   r4   r5   r   r   r   r   r   <module>   s   	
%