Skip to content

Commit 23c301d

Browse files
facelessuserwaylan
authored andcommitted
Fix failing cases for Python 3.14
New change requires us to monkey patch `locatetagend` to prevent capturing incomplete tags in code spans.
1 parent 4669a09 commit 23c301d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

docs/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ and this project adheres to the
1010
[Python Version Specification](https://packaging.python.org/en/latest/specifications/version-specifiers/).
1111
See the [Contributing Guide](contributing.md) for details.
1212

13+
## [Unreleased]
14+
15+
### Fixed
16+
17+
* Fix handling of incomplete HTML tags in code spans in Python 3.14.
18+
1319
## [3.8.2] - 2025-06-19
1420

1521
### Fixed

markdown/htmlparser.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@
6969
)?
7070
\s* # trailing whitespace
7171
""", re.VERBOSE)
72+
htmlparser.locatetagend = re.compile(r"""
73+
[a-zA-Z][^`\t\n\r\f />]* # tag name
74+
[\t\n\r\f /]* # optional whitespace before attribute name
75+
(?:(?<=['"\t\n\r\f /])[^`\t\n\r\f />][^\t\n\r\f /=>]* # attribute name
76+
(?:= # value indicator
77+
(?:'[^']*' # LITA-enclosed value
78+
|"[^"]*" # LIT-enclosed value
79+
|(?!['"])[^>\t\n\r\f ]* # bare value
80+
)
81+
)?
82+
[\t\n\r\f /]* # possibly followed by a space
83+
)*
84+
>?
85+
""", re.VERBOSE)
7286

7387
# Match a blank line at the start of a block of text (two newlines).
7488
# The newlines may be preceded by additional whitespace.

0 commit comments

Comments
 (0)