Implement semicolon for page numbers, etc. in footnotes

This commit is contained in:
RunasSudo 2020-12-20 01:14:11 +11:00
parent 205a9a8c82
commit d9e8e02831
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 7 additions and 2 deletions

View File

@ -427,9 +427,9 @@ class FootnoteExtension(markdown.extensions.footnotes.FootnoteExtension):
return div
class FootnoteInlineProcessor(markdown.extensions.footnotes.FootnoteInlineProcessor):
# Override to handle commas
# Override to handle commas and semicolons
def handleMatch(self, m, data):
id = m.group(1).rstrip(',')
id = m.group(1).rstrip(',').split(';')[0]
if id in self.footnotes.footnotes.keys():
sup = ET.Element("sup")
sup.set('class', 'footnote-ref')
@ -437,8 +437,13 @@ class FootnoteInlineProcessor(markdown.extensions.footnotes.FootnoteInlineProces
sup.set('id', self.footnotes.makeFootnoteRefId(id, found=True))
a.set('href', '#' + self.footnotes.makeFootnoteId(id))
a.text = str(list(self.footnotes.footnotes.keys()).index(id) + 1)
a.tail = ''
if ';' in m.group(1):
a.tail += ' ' + m.group(1).rstrip(',').split(';')[1]
if m.group(1).endswith(','):
a.tail = ','
return sup, m.start(0), m.end(0)
else:
return None, None, None