From 3443f98c0b55c7e41adcef217dfd5af739ccd665 Mon Sep 17 00:00:00 2001 From: Ximanta Bhuyan Date: Fri, 16 Oct 2026 20:10:09 +0530 Subject: [PATCH] Fix HtmlStash.reset to clear tag state --- markdown/util.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/markdown/util.py b/markdown/util.py index 29ffa247d..b95451436 100644 --- a/markdown/util.py +++ b/markdown/util.py @@ -245,6 +245,10 @@ def reset(self) -> None: """ Clear the stash. """ self.html_counter = 0 self.rawHtmlBlocks = [] + # Also clear stored tag state so placeholders and tag indices + # don't leak between runs when the same Markdown instance is reused. + self.tag_counter = 0 + self.tag_data = [] def get_placeholder(self, key: int) -> str: return HTML_PLACEHOLDER % key