
    /Vh                        d Z ddlm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y)z
Adds parsing of Definition Lists to Python-Markdown.

See the [documentation](https://Python-Markdown.github.io/extensions/definition_lists)
for details.
    )annotations   )	Extension   )BlockProcessorListIndentProcessorNc                  h    e Zd ZdZ ej
                  d      Z ej
                  d      ZddZddZ	y)	DefListProcessorz Process Definition Lists. z"(^|\n)[ ]{0,3}:[ ]{1,3}(.*?)(\n|$)z^[ ]{0,3}[^ :]c                J    t        | j                  j                  |            S )N)boolREsearch)selfparentblocks      L/home/dcms/DCMS/lib/python3.12/site-packages/markdown/extensions/def_list.pytestzDefListProcessor.test$   s    DGGNN5)**    c                   |j                  d      }| j                  j                  |      }|d |j                          j	                  d      D cg c]"  }|j                         r|j                         $ }}||j                         d  }| j                  j                  |      }|r|d }
}	n| j                  |      \  }	}
|	r"dj                  |j                  d      |	      }	n|j                  d      }	| j                  |      }|s||j                  d|       y|sO|j                  dk(  r@d}|j                  j	                  d      }|j!                  |       | j                  |      }nd}|A|j                  d	k(  r2|}|sDt#        |      r9|d
   j                  dk(  r't#        |d
         rd}nt%        j&                  |d	      }|D ]  }t%        j&                  |d      }||_        ! | j(                  j*                  j-                  |       t%        j&                  |d      }| j(                  j/                  ||	g       | j(                  j*                  j1                          |
r|j                  d|
       y y c c}w )Nr   
z{}
{}r   Fp	looselistlistdldddt)popr   r   startsplitstrip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termtermsr   	no_indentdtheRestsiblingr1   r   r   r   s                   r   runzDefListProcessor.run'   s1   JJqM	GGNN9%:AGGI&,,T2D$6:jjl  D D!%%'(#%%++E2	wAE*JAw
A.A
A..( MM!Y'+ELL&&t,EMM'"nnV,GE7;;$#6BSWBt);BrF# !!&$/B 	D!!"d+BBG	 	e$b$'QC(!MM!W% ]Ds   'JN)r   etree.Elementr   strreturnr   )r   r?   r5   z	list[str]rA   zbool | None)
__name__
__module____qualname____doc__recompiler   r#   r   r>    r   r   r
   r
      s1    %	9	:B2::/0L+3&r   r
   c                  ,    e Zd ZdZddgZ	 g dZ	 ddZy)DefListIndentProcessorz5 Process indented children of definition list items. r   li)r   olulc                j    t        j                  |d      }| j                  j                  ||g       y)z\ Create a new `dd` or `li` (depending on parent) and parse the block with it as the parent. r   N)r.   r/   r0   r3   )r   r   r   r   s       r   create_itemz"DefListIndentProcessor.create_itemf   s,     fd+UG,r   N)r   r?   r   r@   rA   None)rB   rC   rD   rE   
ITEM_TYPES
LIST_TYPESrO   rH   r   r   rJ   rJ   ]   s     ? J,#J'-r   rJ   c                      e Zd ZdZd Zy)DefListExtensionz# Add definition lists to Markdown. c                    |j                   j                  j                  t        |j                         dd       |j                   j                  j                  t	        |j                         dd       y)z9 Add an instance of `DefListProcessor` to `BlockParser`. 	defindentU   deflist   N)r0   blockprocessorsregisterrJ   r
   )r   mds     r   extendMarkdownzDefListExtension.extendMarkdownp   sP    
		!!**+A"))+Lk[]^
		!!**+;BII+F	SUVr   N)rB   rC   rD   rE   r]   rH   r   r   rT   rT   m   s    -Wr   rT   c                     t        di | S )NrH   )rT   )kwargss    r   makeExtensionr`   v   s    %f%%r   )rE   
__future__r    r   rZ   r   r   xml.etree.ElementTreer.   ElementTreerF   r
   rJ   rT   r`   rH   r   r   <module>re      sK    #  A % % 	<&~ <&~-0 - Wy W&r   