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
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ See the [Contributing Guide](contributing.md) for details.

* Update serializer to be non-recursive (#1644).
* Improve ancestor handling in the inline `Treeprocessor` (#1646).
* Fix issue where inline HTML attributes were rejected if they had `<` or `>` in the attribute (#1647).

## [3.11.0] - 2026-09-25

Expand Down
12 changes: 8 additions & 4 deletions markdown/inlinepatterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,14 @@ def build_inlinepatterns(md: Markdown, **kwargs: Any) -> util.Registry[InlinePro
""" Match an automatic email link (`<me@example.com>`). """

HTML_RE = (
r'(<(\/?[a-zA-Z][^<>@ ]*( [^<>]*)?|' # Tag
r'!--(?:(?!<!--|-->).)*--|' # Comment
r'[?](?:(?!<[?]|[?]>).)*[?]|' # Processing instruction
r'!\[CDATA\[(?:(?!<!\[CDATA\[|\]\]>).)*\]\]' # `CDATA`
# Tag
r'''(<(\/?+[a-zA-Z][^\s"'<>@]*+(?:\s+[^\s"'=<>]++(?:\s*+=\s*+(?:"[^"]*+"|'[^']*+'|[^\s"'=<>]++))?+)*+\s*+/?|'''
# Comment
r'!--(?:(?!<!--|-->).)*--|'
# Processing instruction
r'[?](?:(?!<[?]|[?]>).)*[?]|'
# `CDATA`
r'!\[CDATA\[(?:(?!<!\[CDATA\[|\]\]>).)*\]\]'
')>)'
)
""" Match an HTML tag (`<...>`). """
Expand Down
7 changes: 7 additions & 0 deletions tests/test_syntax/inline/test_raw_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ def test_markdown_nested_in_inline_comment(self):
'Example: <!-- [**Bold link**](http://example.com) -->',
'<p>Example: <!-- <a href="http://example.com"><strong>Bold link</strong></a> --></p>'
)

def test_angle_brackets_in_attributes(self):
# https://github.com/Python-Markdown/markdown/issues/1647
self.assertMarkdownRenders(
'<span data-tip-txt="<kbd>Ctrl</kbd>">Anything</span>',
'<p><span data-tip-txt="<kbd>Ctrl</kbd>">Anything</span></p>'
)
Loading