MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / FootnoteTreeprocessor

Class FootnoteTreeprocessor

markdown/extensions/footnotes.py:273–295  ·  view source on GitHub ↗

Build and append footnote div to end of document.

Source from the content-addressed store, hash-verified

271
272
273class FootnoteTreeprocessor(markdown.treeprocessors.Treeprocessor):
274 """ Build and append footnote div to end of document. """
275
276 def __init__ (self, footnotes):
277 self.footnotes = footnotes
278
279 def run(self, root):
280 footnotesDiv = self.footnotes.makeFootnotesDiv(root)
281 if footnotesDiv:
282 result = self.footnotes.findFootnotesPlaceholder(root)
283 if result:
284 node, isText = result
285 if isText:
286 node.text = None
287 node.getchildren().insert(0, footnotesDiv)
288 else:
289 child, element = node
290 ind = element.getchildren().find(child)
291 element.getchildren().insert(ind + 1, footnotesDiv)
292 child.tail = None
293 fnPlaceholder.parent.replaceChild(fnPlaceholder, footnotesDiv)
294 else:
295 root.append(footnotesDiv)
296
297class FootnotePostprocessor(markdown.postprocessors.Postprocessor):
298 """ Replace placeholders with html entities. """

Callers 1

extendMarkdownMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected