diff --git a/docs/changelog.md b/docs/changelog.md index d81e66ae3..3d54e6e2f 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 handling of incomplete HTML tags in code spans in Python 3.14. + ## [3.8.2] - 2025-06-19 ### Fixed diff --git a/markdown/htmlparser.py b/markdown/htmlparser.py index 478e70216..63e5df31b 100644 --- a/markdown/htmlparser.py +++ b/markdown/htmlparser.py @@ -69,6 +69,20 @@ )? \s* # trailing whitespace """, re.VERBOSE) +htmlparser.locatetagend = re.compile(r""" + [a-zA-Z][^`\t\n\r\f />]* # tag name + [\t\n\r\f /]* # optional whitespace before attribute name + (?:(?<=['"\t\n\r\f /])[^`\t\n\r\f />][^\t\n\r\f /=>]* # attribute name + (?:= # value indicator + (?:'[^']*' # LITA-enclosed value + |"[^"]*" # LIT-enclosed value + |(?!['"])[^>\t\n\r\f ]* # bare value + ) + )? + [\t\n\r\f /]* # possibly followed by a space + )* + >? +""", re.VERBOSE) # Match a blank line at the start of a block of text (two newlines). # The newlines may be preceded by additional whitespace.