Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion markdown/htmlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<')
Expand Down
26 changes: 26 additions & 0 deletions tests/test_syntax/blocks/test_html_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1706,3 +1706,29 @@ def test_no_hang_issue_1586(self):
'Test `<!--[if mso]>` and `<!--[if !mso]>`',
'<p>Test <code>&lt;!--[if mso]&gt;</code> and <code>&lt;!--[if !mso]&gt;</code></p>'
)

def test_issue_1590(self):
"""Test case with comments in table for issue #1590."""

self.assertMarkdownRenders(
self.dedent(
'''
<table>
<!--[if mso]>-->
<td>foo</td>
<!--<!endif]-->
<td>bar</td>
</table>
'''
),
self.dedent(
'''
<table>
<!--[if mso]>-->
<td>foo</td>
<!--<!endif]-->
<td>bar</td>
</table>
'''
)
)