\@sdZddlmZddlmZddlmZddlmZmZddl m Z dd l Z Gd d d eZ Gd d d eZ GdddeZiddZd S)a Definition List Extension for Python-Markdown ============================================= Added parsing of Definition Lists to Python-Markdown. A simple example: Apple : Pomaceous fruit of plants of the genus Malus in the family Rosaceae. : An american computer company. Orange : The fruit of an evergreen tree of the genus Citrus. Copyright 2008 - [Waylan Limberg](http://achinghead.com) )absolute_import)unicode_literals) Extension)BlockProcessorListIndentProcessor)etreeNc@sLeZdZdZejdZejdZddZddZ dS) DefListProcessorz Process Definition Lists. z"(^|\n)[ ]{0,3}:[ ]{1,3}(.*?)(\n|$)z^[ ]{0,3}[^ :]cCst|jj|S)N)boolREsearch)selfparentblockr)build/lib/markdown/extensions/def_list.pytest#szDefListProcessor.testcCs]|jd}|jj|}dd|d|jjdD}||jd}|jj|}|r|d}} n|j|\}} |rd|j d|f}n|j d}|j |} | r| dkr|j d|dS| rT| j dkrTd } | j jd}|j| |j |} nd } | r| j d kr| } | rt| r| dj d krt| drd } qntj|d } x)|D]!} tj| d}| |_ qW|jjj| tj| d }|jj||g|jjj| rY|j d| ndS)NrcSs(g|]}|jr|jqSr)strip).0lrrr *s z(DefListProcessor.run.. z%s %srFp looselistlistdlrdddtr)popr r startsplitend NO_INDENT_REmatchdetabgroup lastChildinserttagtextremovelenr SubElementparserstateset parseBlocksreset)rrblocksZ raw_blockmZtermsrZ no_indentdtheRestsiblingr0rZtermrrrrrrun&sF, 6   zDefListProcessor.runN) __name__ __module__ __qualname____doc__recompiler r$rr9rrrrr s  r c@s4eZdZdZdgZdgZddZdS)DefListIndentProcessorz5 Process indented children of definition list items. rrcCs,tj|d}|jj||gdS)z< Create a new dd and parse the block with it as the parent. rN)r r.r/r2)rrrrrrr create_item`sz"DefListIndentProcessor.create_itemN)r:r;r<r= ITEM_TYPES LIST_TYPESrArrrrr@Zs   r@c@s"eZdZdZddZdS)DefListExtensionz# Add definition lists to Markdown. cCsH|jjjdt|jd|jjjdt|jddS)z5 Add an instance of DefListProcessor to BlockParser. Z defindentz>indentZdeflistz>ulistN)r/blockprocessorsaddr@r )rmd md_globalsrrrextendMarkdownjs   zDefListExtension.extendMarkdownN)r:r;r<r=rIrrrrrDgs rDcCs td|S)Nconfigs)rD)rJrrr makeExtensiontsrK)r= __future__rrrrErrutilr r>r r@rDrKrrrrs =