From d9e8e02831d68866a10c15d9397cd028876ce0c0 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sun, 20 Dec 2020 01:14:11 +1100 Subject: [PATCH] Implement semicolon for page numbers, etc. in footnotes --- wikinote/markup.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wikinote/markup.py b/wikinote/markup.py index 50d09ce..afc974b 100644 --- a/wikinote/markup.py +++ b/wikinote/markup.py @@ -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