diff --git a/src/dragonglass/mparse.py b/src/dragonglass/mparse.py index fb5c82b..55e2a0d 100644 --- a/src/dragonglass/mparse.py +++ b/src/dragonglass/mparse.py @@ -331,6 +331,10 @@ class ObsidianStyleFootnotes(FootnoteExtension): """A block processor extended to handle Obsidian inline footnotes.""" RE_INLINE = re.compile(r'\^\[(.+)]') + def __init__(self, footnotes: FootnoteExtension) -> None: + super(ObsidianStyleFootnotes.BlockProcessor, self).__init__(footnotes) + self._inlines_nonce = 0 + def run(self, parent: etree.Element, blocks: list[str]) -> bool: """ Find, set, and remove footnote definitions. """ block = blocks.pop(0) @@ -373,7 +377,8 @@ class ObsidianStyleFootnotes(FootnoteExtension): if m_inline: footnote = m_inline.group(1).strip() - id = hashlib.sha1(bytes(footnote, 'utf-8')).hexdigest() + id = hashlib.sha1(bytes(f"{footnote}{self._inlines_nonce}", 'utf-8')).hexdigest() + self._inlines_nonce += 1 self.footnotes.setFootnote(id, footnote) blocks.insert(0, block[:m_inline.start(0)].rstrip() + INLINE_FOOTNOTE_REF_PATTERN.format(id) + block[m_inline.end(0):])