Skip to content

Fix issue with handling </>#4007

Closed
facelessuser wants to merge 2 commits into
mkdocs:masterfrom
facelessuser:bugfix/bad-tag
Closed

Fix issue with handling </>#4007
facelessuser wants to merge 2 commits into
mkdocs:masterfrom
facelessuser:bugfix/bad-tag

Conversation

@facelessuser

@facelessuser facelessuser commented Jul 2, 2025

Copy link
Copy Markdown
Contributor

Markdown recently made a fix for an issue handling </> which would get stripped out of content. Reference:
Python-Markdown/markdown@64a3c0f

MkDocs uses Markdown's monkey-patched HTMLParser, but does not use the HTML extractor that has the logic to handle the things that have been monkey-patched in. Because of this, MkDocs now fails when parsing </>. This fixes the issue by adding the same logic to handle the issue that Markdown uses.

Fixes #4001

Markdown recently made a fix for an issue handling `</>` which would get
stripped out of content. Reference:
Python-Markdown/markdown@64a3c0f

MkDocs uses Markdown's monkey-patched HTMLParser, but does not use the
HTML extractor that has the logic to handle the things that have been
monkey-patched in. Because of this, MkDocs now fails when parsing
`</>`. This fixes the issue by adding the same logic to handle the issue
that Markdown uses.
@facelessuser

Copy link
Copy Markdown
Contributor Author

This fixes #4001

@facelessuser

Copy link
Copy Markdown
Contributor Author

@tomchristie is this project still being maintained? I'd love to see this bug fix get merged and released.

@maxpollack

Copy link
Copy Markdown

+1, this broke our team's internal docs build. can this get merged?

@facelessuser

Copy link
Copy Markdown
Contributor Author

It seems I am unable to push this forward. I am willing to provide changes and updates if the Mkdocs team is willing to engage. If not, I guess we are not getting this fix.

@Guts

Guts commented Nov 6, 2025

Copy link
Copy Markdown

I guess we should ping @lovelydinosaur

@thomasborgen

Copy link
Copy Markdown

We also need this fix 🙏🏼

@SOV710

SOV710 commented Jan 15, 2026

Copy link
Copy Markdown

This bug is breaking our documentation. MkDocs team, would it be possible to merge this PR and release 6.1.2? Much appreciated!

@facelessuser

Copy link
Copy Markdown
Contributor Author

I had to fix some other HTML issues in Python Markdown. Because it broke MkDocs for Python Markdown, I had to resort to hackery. The good news is that the next Python Markdown, will fix this issue for MkDocs. PR is here: Python-Markdown/markdown#1593.

@mschoettle

Copy link
Copy Markdown

@facelessuser Thanks a lot! I just updated markdown to 3.10.2 and </> now renders as is 👍

@facelessuser

Copy link
Copy Markdown
Contributor Author

Yep, it was one of those things; it hadn't occurred to me that it could be fixed in Python Markdown. I'd argue it shouldn't have had to be fixed there, but necessity is the mother of invention. When Python Markdown, which uses MkDocs as its documentation engine, was now breaking due to this, a solution became necessary.

@themavik themavik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overriding parse_starttag to push </> through handle_data stops AnchorHtmlValidator from treating that JSX fragment as a real closing tag. nit: this couples you to CPython HTMLParser internals—if the stdlib parser changes, this hook is the first place to re-test.

@facelessuser

Copy link
Copy Markdown
Contributor Author

This isn't needed anymore, as a fix that works here is available in the latest Python Markdown directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AssertionError: we should not get here! from html.parser with Python 3.13.5

7 participants