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] == '': self.handle_data('<') diff --git a/tests/test_syntax/blocks/test_html_blocks.py b/tests/test_syntax/blocks/test_html_blocks.py index 406de997..87d4dc0b 100644 --- a/tests/test_syntax/blocks/test_html_blocks.py +++ b/tests/test_syntax/blocks/test_html_blocks.py @@ -1706,3 +1706,29 @@ def test_no_hang_issue_1586(self): 'Test ` +
| foo | + +bar | +