diff --git a/docs/changelog.md b/docs/changelog.md index 83e33c7c..a11b6c9f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -10,6 +10,12 @@ and this project adheres to the [Python Version Specification](https://packaging.python.org/en/latest/specifications/version-specifiers/). See the [Contributing Guide](contributing.md) for details. +## [Unreleased] + +### Fixed + +* Fix a regression related to comment handling (#1590). + ## [3.10.1] - 2026-01-21 ### Fixed diff --git a/markdown/htmlparser.py b/markdown/htmlparser.py index 74dbe25a..55d46345 100644 --- a/markdown/htmlparser.py +++ b/markdown/htmlparser.py @@ -276,7 +276,7 @@ def handle_entityref(self, name: str): def handle_comment(self, data: str): # Check if the comment is unclosed, if so, we need to override position - j = len(self.rawdata) - len(data) + j = self.rawdata.find(data) i = j - 2 if self.rawdata[i:j] == '` and ` + foo + + bar + + ''' + ), + self.dedent( + ''' + + + + + +
foobar
+ ''' + ) + )