-
Notifications
You must be signed in to change notification settings - Fork 702
python-markdown: fix html.parser incompatibility with Python 3.12.14 #18780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kgodara912
wants to merge
1
commit into
3.0-dev
Choose a base branch
from
kgodara/3.0-dev/python-markdown_fix
base: 3.0-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+52
−5
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
SPECS/python-markdown/0002-Fix-handling-of-incomplete-HTML-tags-in-code-spans.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| From 15346cd3a73f108bf11c57907b32737f8365d6bd Mon Sep 17 00:00:00 2001 | ||
| From: facelessuser <faceless.shop@gmail.com> | ||
| Date: Mon, 21 Jul 2025 08:56:43 -0600 | ||
| Subject: [PATCH] Fix failing cases for Python 3.14 | ||
|
|
||
| New change requires us to monkey patch `locatetagend` to prevent | ||
| capturing incomplete tags in code spans. | ||
|
|
||
| Upstream: https://github.com/Python-Markdown/markdown/pull/1548 | ||
| (released in Python-Markdown 3.9.0) | ||
|
|
||
| The `docs/changelog.md` hunk of the upstream commit is dropped as the | ||
| file is not shipped in the sdist used here. | ||
| --- | ||
| markdown/htmlparser.py | 14 ++++++++++++++ | ||
| 1 file changed, 14 insertions(+) | ||
|
|
||
| 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 @@ htmlparser.locatestarttagend_tolerant = re.compile(r""" | ||
| )? | ||
| \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. | ||
| -- | ||
| 2.51.0 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,14 +3,15 @@ | |
| Summary: Markdown implementation in Python | ||
| Name: python-%{pkgname} | ||
| Version: 3.8.2 | ||
| Release: 2%{?dist} | ||
| Release: 3%{?dist} | ||
| License: BSD-3-Clause | ||
| Vendor: Microsoft Corporation | ||
| Distribution: Azure Linux | ||
| URL: https://python-markdown.github.io/ | ||
| Source0: https://github.com/Python-Markdown/markdown/releases/download/%{version}/%{pkgname}-%{version}.tar.gz#/python-%{srcname}-%{version}.tar.gz | ||
| BuildArch: noarch | ||
| Patch0: 0001-fix-pyproject-license-for-setuptools.patch | ||
| Patch1: 0002-Fix-handling-of-incomplete-HTML-tags-in-code-spans.patch | ||
|
|
||
| %description | ||
| This is a Python implementation of John Grubers Markdown. It is | ||
|
|
@@ -37,9 +38,6 @@ there are a few known issues. | |
|
|
||
| %prep | ||
| %autosetup -p1 -n %{pkgname}-%{version} | ||
| # Skip 2 tests that fail due to Python 3.12 html.parser behavior changes | ||
| sed -i 's/def test_raw_missing_close_bracket/def _skip_test_raw_missing_close_bracket/' tests/test_syntax/blocks/test_html_blocks.py | ||
| sed -i 's/def test_unclosed_comment_/def _skip_test_unclosed_comment_/' tests/test_syntax/blocks/test_html_blocks.py | ||
|
|
||
| %build | ||
| %pyproject_wheel | ||
|
|
@@ -53,7 +51,6 @@ PYTHONPATH=%{buildroot}%{python3_sitelib} \ | |
| LICENSE.md > LICENSE.html | ||
|
|
||
| %check | ||
| # Skip test_raw_missing_close_bracket and test_unclosed_comment_ (Python 3.12 html.parser changes) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🥇 |
||
| %{__python3} -m unittest discover -v | ||
|
|
||
|
|
||
|
|
@@ -66,6 +63,11 @@ PYTHONPATH=%{buildroot}%{python3_sitelib} \ | |
| %{_bindir}/markdown_py | ||
|
|
||
| %changelog | ||
| * Thu Sep 10 2026 Kshitiz Godara <kgodara@microsoft.com> - 3.8.2-3 | ||
| - Add upstream patch (PR #1548) to fix incomplete HTML tags in code spans | ||
| with the new html.parser backported into Python 3.12.14. | ||
| - Drop the %%prep test skips, no longer needed with Python 3.12.14. | ||
|
|
||
| * Wed Jun 17 2026 Kshitiz Godara <kgodara@microsoft.com> - 3.8.2-2 | ||
| - Use %%{pkgname} (lowercase) for %%autosetup -n so the directory inside | ||
| the upstream tarball (markdown-3.8.2) matches; skip 2 tests broken by | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.