ó Šç\c@@sPdZddlmZddlmZddlmZddlmZddlm Z dd l m Z dd l m Z dd lmZmZdd lmZdd lZdZdZejdƒZejdƒZdefd„ƒYZdefd„ƒYZde fd„ƒYZde fd„ƒYZde fd„ƒYZgd„Zd S(u† ========================= FOOTNOTES ================================= This section adds footnote handling to markdown. It can be used as an example for extending python-markdown with relatively complex functionality. While in this case the extension is included inside the module itself, it could just as easily be added from outside the module. Not that all markdown classes above are ignorant about footnotes. All footnote functionality is provided separately and then added to the markdown instance at the run time. Footnote functionality is attached by calling extendMarkdown() method of FootnoteExtension. The method also registers the extension to allow it's state to be reset by a call to reset() method. Example: Footnotes[^1] have a label[^label] and a definition[^!DEF]. [^1]: This is a footnote [^label]: A footnote on "label" [^!DEF]: The footnote for definition i(tabsolute_import(tunicode_literalsi(t Extensioni(t Preprocessor(tPattern(t Treeprocessor(t Postprocessor(tetreet text_type(t OrderedDictNuzz1337820767766393qquqq3936677670287331zzu[ ]{0,3}\[\^([^\]]*)\]:\s*(.*)u((\t)|( ))(.*)tFootnoteExtensioncB@s_eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z RS( u Footnote Extension. cC@soiddgd6tdgd6ddgd6|_x%|D]\}}||j|d amp_substituteN( tregisterExtensiontparsertmdt preprocessorstaddtFootnotePreprocessortinlinePatternstFootnotePatternttreeprocessorstFootnoteTreeprocessortpostprocessorstFootnotePostprocessor(RRt md_globalst FOOTNOTE_RE((sA/usr/lib/python2.7/site-packages/markdown/extensions/footnotes.pytextendMarkdownCs   cC@stƒ|_|jd7_dS(uD Clear the footnotes on reset, and prepare for a distinct document. iN(R t footnotesR (R((sA/usr/lib/python2.7/site-packages/markdown/extensions/footnotes.pyRXs c@s"‡‡fd†‰ˆ|ƒ}|S(u@ Return ElementTree Element that contains Footnote placeholder. c@s“xŒ|D]„}|jrG|jjˆjdƒƒdkrG||tfSn|jr|jjˆjdƒƒdkr||tfSnˆ|ƒqWdS(Nu PLACE_MARKERiÿÿÿÿ(ttexttfindt getConfigtTruettailR tNone(telementtchild(tfinderR(sA/usr/lib/python2.7/site-packages/markdown/extensions/footnotes.pyR,_s  ! !((Rtroottres((R,RsA/usr/lib/python2.7/site-packages/markdown/extensions/footnotes.pytfindFootnotesPlaceholder]s cC@s||j|R<tremoveROR)R(RA(RR-t footnotesDivtresultR+tparenttisTexttind((sA/usr/lib/python2.7/site-packages/markdown/extensions/footnotes.pyRYs  (RIRJRKRRY(((sA/usr/lib/python2.7/site-packages/markdown/extensions/footnotes.pyRs RcB@s eZdZd„Zd„ZRS(u* Replace placeholders with html entities. cC@s ||_dS(N(R#(RR#((sA/usr/lib/python2.7/site-packages/markdown/extensions/footnotes.pyR1scC@s.|jt|jjdƒƒ}|jtdƒS(Nu BACKLINK_TEXTu (treplaceR=R#R&R@(RR$((sA/usr/lib/python2.7/site-packages/markdown/extensions/footnotes.pyRY4s(RIRJRKRRY(((sA/usr/lib/python2.7/site-packages/markdown/extensions/footnotes.pyR/s cC@s td|ƒS(u- Return an instance of the FootnoteExtension R(R (R((sA/usr/lib/python2.7/site-packages/markdown/extensions/footnotes.pyt makeExtension8s(RKt __future__RRtRRRtinlinepatternsRRRRRtutilRRtodictR treR=R@tcompileRLRZR RRRRRp(((sA/usr/lib/python2.7/site-packages/markdown/extensions/footnotes.pyts( }[