InlinePattern for footnote markers in a document's body text.
| 253 | |
| 254 | |
| 255 | class 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 | |
| 273 | class FootnoteTreeprocessor(markdown.treeprocessors.Treeprocessor): |