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

Class FootnotePattern

markdown/extensions/footnotes.py:255–270  ·  view source on GitHub ↗

InlinePattern for footnote markers in a document's body text.

Source from the content-addressed store, hash-verified

253
254
255class FootnotePattern(markdown.inlinepatterns.Pattern):
256 """ InlinePattern for footnote markers in a document's body text. """
257
258 def __init__(self, pattern, footnotes):
259 markdown.inlinepatterns.Pattern.__init__(self, pattern)
260 self.footnotes = footnotes
261
262 def handleMatch(self, m):
263 sup = etree.Element("sup")
264 a = etree.SubElement(sup, "a")
265 id = m.group(2)
266 sup.set('id', self.footnotes.makeFootnoteRefId(id))
267 a.set('href', '#' + self.footnotes.makeFootnoteId(id))
268 a.set('rel', 'footnote')
269 a.text = str(self.footnotes.footnotes.index(id) + 1)
270 return sup
271
272
273class FootnoteTreeprocessor(markdown.treeprocessors.Treeprocessor):

Callers 1

extendMarkdownMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected