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

* Ensure nested elements inside inline comments are properly unescaped (#1571).

## [3.10.0] - 2025-11-03

### Changed
Expand Down
3 changes: 2 additions & 1 deletion markdown/inlinepatterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,8 @@ def get_stash(m: re.Match[str]) -> str:
value = stash.get(id)
if value is not None:
try:
return self.md.serializer(value)
# Ensure we don't have a placeholder inside a placeholder
return self.unescape(self.md.serializer(value))
except Exception:
return r'\%s' % value

Expand Down
6 changes: 6 additions & 0 deletions tests/test_syntax/inline/test_raw_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ def test_inline_html_backslashes(self):

def test_noname_tag(self):
self.assertMarkdownRenders('<span></></span>', '<p><span>&lt;/&gt;</span></p>')

def test_markdown_nested_in_inline_comment(self):
self.assertMarkdownRenders(
'Example: <!-- [**Bold link**](http://example.com) -->',
'<p>Example: <!-- <a href="http://example.com"><strong>Bold link</strong></a> --></p>'
)
Loading