Ñò éíÑXc@sñdZddkZddkZddklZdZdZeidƒZeidƒZdei fd „ƒYZ d ei i fd „ƒYZ d eiifd „ƒYZdeiifd„ƒYZdeiifd„ƒYZgd„ZdS(s† ========================= 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ÿÿÿÿN(tetreetzz1337820767766393qqtqq3936677670287331zzs!(\ ?\ ?\ ?)\[\^([^\]]*)\]:\s*(.*)s((\t)|( ))(.*)tFootnoteExtensioncBsVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( s Footnote Extension. cCsLhddgd6|_x%|D]\}}||i|damp_substituteN( tregisterExtensiontparsert preprocessorstaddtFootnotePreprocessortinlinePatternstFootnotePatternttreeprocessorstFootnoteTreeprocessortpostprocessorstFootnotePostprocessor(Rtmdt md_globalst FOOTNOTE_RE((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pytextendMarkdown0s  cCstiiƒ|_dS(s Clear the footnotes on reset. N(tmarkdowntodictt OrderedDictt footnotes(R((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyRDscs"‡‡fd†‰ˆ|ƒ}|S(s@ Return ElementTree Element that contains Footnote placeholder. cs›x”|D]Œ}|io1|iiˆidƒƒdjo |tfSn|io7|iiˆidƒƒdjo||ftfSnˆ|ƒqWdS(NRiÿÿÿÿ(ttexttfindt getConfigtTruettailtFalsetNone(telementtchild(Rtfinder(sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyR)Js " "((Rtroottres((RR)sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pytfindFootnotesPlaceholderHs cCs||i|t|t|ƒƒD]&}||iƒo||}Pq˜q˜WP||ƒo|idƒq"q"Pq"W|d7}|||fS(só Find indented text and remove indent before further proccesing. Keyword arguments: * lines: an array of strings Returns: a list of post processed items and the unused remainder of the original list iÿÿÿÿicSs(ti|ƒ}|o|idƒSdS(Ni(t TABBED_RER[R\(R^R[((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pytdetabÌsiRR(tstripRFtrangetlen( RRPtitemstitemRURaR^tjt next_line((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyRT½s4           (RJRKRLR RQRMRSRT(((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyR…s     RcBs eZdZd„Zd„ZRS(s? InlinePattern for footnote markers in a document's body text. cCs#tiii||ƒ||_dS(N(RtinlinepatternstPatternR R(RtpatternR((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyR ôscCs¢tidƒ}ti|dƒ}|idƒ}|id|ii|ƒƒ|idd|ii|ƒƒ|iddƒt|iii |ƒd ƒ|_ |S( NtsupR6iR-R7R8trelR i( RR=R?R\R>RR0R/tstrRAR (RR_RlR6R-((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyt handleMatchøs "(RJRKRLR Ro(((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyRñs RcBs eZdZd„Zd„ZRS(s3 Build and append footnote div to end of document. cCs ||_dS(N(R(RR((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyR sc CsØ|ii|ƒ}|o»|ii|ƒ}|o‘|\}}|o#d|_|iƒid|ƒnE|\}}|iƒi|ƒ}|iƒi|d|ƒd|_t i i t |ƒqÔ|i |ƒndS(Nii( RRIR,R&R RCtinsertR!R$t fnPlaceholdertparentt replaceChildRF( RR*t footnotesDivtresultRHtisTextR(R'tind((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyRQ s    (RJRKRLR RQ(((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyRs RcBseZdZd„ZRS(s* Replace placeholders with html entities. cCs"|itdƒ}|itdƒS(Ns↩s (treplaceRBRE(RR ((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyRQs(RJRKRLRQ(((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyRscCs td|ƒS(s- Return an instance of the FootnoteExtension R(R(R((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pyt makeExtension"s(RLtreRRRBREtcompileRZR`t ExtensionRRt PreprocessorRRiRjRRt TreeprocessorRRt PostprocessorRRy(((sA/usr/lib/python2.6/site-packages/markdown/extensions/footnotes.pytscl