ó Šç\c@@sºdZddlmZddlmZddlmZddlmZmZddl m Z dd l Z d efd „ƒYZ d efd „ƒYZ defd„ƒYZid„Zd S(u± 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) i(tabsolute_import(tunicode_literalsi(t Extensioni(tBlockProcessortListIndentProcessor(tetreeNtDefListProcessorcB@s>eZdZejdƒZejdƒZd„Zd„ZRS(u Process Definition Lists. u"(^|\n)[ ]{0,3}:[ ]{1,3}(.*?)(\n|$)u^[ ]{0,3}[^ :]cC@st|jj|ƒƒS(N(tbooltREtsearch(tselftparenttblock((s@/usr/lib/python2.7/site-packages/markdown/extensions/def_list.pyttest#sc C@si|jdƒ}|jj|ƒ}g||jƒ jdƒD]}|jƒr;|jƒ^q;}||jƒ}|jj|ƒ}|r—|d} } n|j |ƒ\} } | rÎd|j dƒ| f} n|j dƒ} |j |ƒ} | r| dkr|j d|ƒtS| r`| jdkr`d} | jjdƒ}|j| ƒ|j |ƒ} nd} | rÃ| jdkrÃ| } | rÕt| ƒrÕ| d jd krÕt| d ƒrÕd} qÕntj|dƒ} x)|D]!}tj| d ƒ}||_qÜW|jjj| ƒtj| d ƒ}|jj|| gƒ|jjjƒ| re|j d| ƒndS( Niu u%s %siupu looselistulistudliÿÿÿÿuddudt(tpopRR tstarttsplittstriptendt NO_INDENT_REtmatchtNonetdetabtgroupt lastChildtinserttFalsettagttexttremovetlenRt SubElementtparsertstatetsett parseBlockstreset(R R tblockst raw_blocktmtlttermsR t no_indenttdttheResttsiblingR!tdlttermtdttdd((s@/usr/lib/python2.7/site-packages/markdown/extensions/def_list.pytrun&sF> 6   ( t__name__t __module__t__doc__tretcompileRRR R2(((s@/usr/lib/python2.7/site-packages/markdown/extensions/def_list.pyRs  tDefListIndentProcessorcB@s)eZdZdgZdgZd„ZRS(u5 Process indented children of definition list items. uddudlcC@s,tj|dƒ}|jj||gƒdS(u< Create a new dd and parse the block with it as the parent. uddN(RRR R#(R R R R1((s@/usr/lib/python2.7/site-packages/markdown/extensions/def_list.pyt create_item`s(R3R4R5t ITEM_TYPESt LIST_TYPESR9(((s@/usr/lib/python2.7/site-packages/markdown/extensions/def_list.pyR8Zs  tDefListExtensioncB@seZdZd„ZRS(u# Add definition lists to Markdown. cC@sH|jjjdt|jƒdƒ|jjjdt|jƒdƒdS(u5 Add an instance of DefListProcessor to BlockParser. u defindentu>indentudeflistu>ulistN(R tblockprocessorstaddR8R(R tmdt md_globals((s@/usr/lib/python2.7/site-packages/markdown/extensions/def_list.pytextendMarkdownjs   (R3R4R5RA(((s@/usr/lib/python2.7/site-packages/markdown/extensions/def_list.pyR<gscC@s td|ƒS(Ntconfigs(R<(RB((s@/usr/lib/python2.7/site-packages/markdown/extensions/def_list.pyt makeExtensionts(R5t __future__RRtRR=RRtutilRR6RR8R<RC(((s@/usr/lib/python2.7/site-packages/markdown/extensions/def_list.pyts =