
    c3                         d Z ddlmZ ddlmZmZ ddlmc mZ ddl	Z	 G d de          Z
 G d	 d
e          Z G d de          Zd ZdS )a  
Definition List Extension for Python-Markdown
=============================================

Adds parsing of Definition Lists to Python-Markdown.

See <https://Python-Markdown.github.io/extensions/definition_lists>
for documentation.

Original code Copyright 2008 [Waylan Limberg](http://achinghead.com)

All changes Copyright 2008-2014 The Python Markdown Project

License: [BSD](https://opensource.org/licenses/bsd-license.php)

   )	Extension   )BlockProcessorListIndentProcessor    Nc                   ^    e Zd ZdZ ej        d          Z ej        d          Zd Zd Z	dS )DefListProcessorz Process Definition Lists. z"(^|\n)[ ]{0,3}:[ ]{1,3}(.*?)(\n|$)z^[ ]{0,3}[^ :]c                 P    t          | j                            |                    S )N)boolREsearch)selfparentblocks      <lib/python3.11/site-packages/markdown/extensions/def_list.pytestzDefListProcessor.test   s    DGNN5))***    c                    |                     d          }| j                            |          }d |d |                                                             d          D             }||                                d          }| j                            |          }|r|d }	}n|                     |          \  }}	|r*d	                    |
                    d          |          }n|
                    d          }|                     |          }
|s|
|                    d|           dS |sR|
j        dk    rGd}|
j                            d          }|                    |
           |                     |          }
nd	}|
G|
j        d
k    r<|
}|s7t!          |          r(|d         j        dk    rt!          |d                   rd}nt#          j        |d
          }|D ]}t#          j        |d          }||_        | j        j                            |           t#          j        |d          }| j                            ||g           | j        j                                         |	r|                    d|	           d S d S )Nr   c                 ^    g | ]*}|                                 |                                 +S  )strip).0terms     r   
<listcomp>z(DefListProcessor.run.<locals>.<listcomp>%   sC     D D D$6:jjllD D D Dr   
z{}
{}r   Fp	looselistlistdldddt)popr   r   startsplitendNO_INDENT_REmatchdetabformatgroup	lastChildinserttagtextremovelenetree
SubElementparserstatesetparseBlocksreset)r   r   blocks	raw_blockmtermsr   	no_indentdtheRestsiblingr5   r   r   r"   r!   s                   r   runzDefListProcessor.run!   s   JJqMM	GNN9%%D D:AGGII:&,,T22D D D!%%''((#%++E22	 	+wAAE**JAw 	

A..AA

A..(( 	 	 MM!Y'''5 	+ 	EL&&t,,EMM'"""nnV,,GGE 	07;$#6 	0B $SWW $Bt); $BrF $# !&$//B 	 	D!"d++BBGGe$$$b$''QC(((!!! 	&MM!W%%%%%	& 	&r   N)
__name__
__module____qualname____doc__recompiler   r'   r   rA   r   r   r   r	   r	      s\        %%	9	:	:B2:/00L+ + +3& 3& 3& 3& 3&r   r	   c                   (    e Zd ZdZddgZg dZd ZdS )DefListIndentProcessorz5 Process indented children of definition list items. r!   li)r   olulc                 h    t          j        |d          }| j                            ||g           dS )zX Create a new dd or li (depending on parent) and parse the block with it as the parent. r!   N)r2   r3   r4   r7   )r   r   r   r!   s       r   create_itemz"DefListIndentProcessor.create_item^   s6     fd++UG,,,,,r   N)rB   rC   rD   rE   
ITEM_TYPES
LIST_TYPESrN   r   r   r   rI   rI   W   s?        ?? J###J- - - - -r   rI   c                       e Zd ZdZd ZdS )DefListExtensionz# Add definition lists to Markdown. c                     |j         j                            t          |j                   dd           |j         j                            t	          |j                   dd           dS )z5 Add an instance of DefListProcessor to BlockParser. 	defindentU   deflist   N)r4   blockprocessorsregisterrI   r	   )r   mds     r   extendMarkdownzDefListExtension.extendMarkdownh   sZ    
	!**+A")+L+Lk[]^^^
	!**+;BI+F+F	SUVVVVVr   N)rB   rC   rD   rE   r[   r   r   r   rR   rR   e   s.        --W W W W Wr   rR   c                      t          di | S )Nr   )rR   )kwargss    r   makeExtensionr^   n   s    %%f%%%r   )rE    r   rX   r   r   xml.etree.ElementTreer2   ElementTreerF   r	   rI   rR   r^   r   r   r   <module>rb      s    "       A A A A A A A A % % % % % % % % % 				<& <& <& <& <&~ <& <& <&~- - - - -0 - - -W W W W Wy W W W& & & & &r   