From d61cae613ddec71106e81e419b307f25a6983bf2 Mon Sep 17 00:00:00 2001 From: Naaz nuria Date: Sat, 24 Oct 2026 17:55:21 +0530 Subject: [PATCH 1/2] Avoid rescanning for a comment close after unclosed comments `HTMLExtractor.parse_comment` searches for `-->` (or `--!>`) from each ``). * Fix regression in `BacktickInlineProcessor` where text could be lost when opening and closing backticks did not match (#1668). * Escape the language name in the `codehilite` extension's non-Pygments output to diff --git a/markdown/htmlparser.py b/markdown/htmlparser.py index fe067e70..78c9e04f 100644 --- a/markdown/htmlparser.py +++ b/markdown/htmlparser.py @@ -158,6 +158,8 @@ def reset(self): self._cache: list[str] = [] self.cleandoc: list[str] = [] self.lineno_start_cache = [0] + # The `rawdata` and position of the last failed search for a comment close. + self._no_commentclose: tuple[str | None, int] = (None, 0) super().reset() @@ -359,8 +361,15 @@ def parse_pi(self, i: int) -> int: def parse_comment(self, i, report=True): rawdata = self.rawdata assert rawdata.startswith('