Skip to content

Fix handle AssertionError from html.parser on edge-case markup#51

Merged
shenxianpeng merged 1 commit into
mainfrom
fix-4001-html-parser-assertion
Apr 27, 2026
Merged

Fix handle AssertionError from html.parser on edge-case markup#51
shenxianpeng merged 1 commit into
mainfrom
fix-4001-html-parser-assertion

Conversation

@shenxianpeng
Copy link
Copy Markdown
Member

@shenxianpeng shenxianpeng commented Apr 27, 2026

Python 3.13's html.parser throws AssertionError when encountering certain edge-case markup like <<>> in the content. This occurs in the _RawHTMLPreprocessor which feeds raw markdown into HTMLParser to extract anchor IDs.

Wrap the parser.feed() call in a try/except to catch AssertionError and RuntimeError, allowing the build to continue gracefully.

Fixes mkdocs/mkdocs#4001

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / code cleanup
  • CI / build / dependency update
  • Other (describe below)

Checklist

  • New tests added for new behavior (if applicable)
  • Documentation updated (if applicable)
  • Release notes docs/about/release-notes.md updated (if applicable)

@github-actions github-actions Bot added the bug Something isn't working label Apr 27, 2026
Python 3.13's html.parser throws AssertionError when encountering certain
edge-case markup like `<<>>` in the content. This occurs in the
_RawHTMLPreprocessor which feeds raw markdown into HTMLParser to extract
anchor IDs.

Wrap the parser.feed() call in a try/except to catch AssertionError and
RuntimeError, allowing the build to continue gracefully.

Fixes #4001
@shenxianpeng shenxianpeng force-pushed the fix-4001-html-parser-assertion branch from 7952230 to 639a28d Compare April 27, 2026 16:39
@shenxianpeng shenxianpeng changed the title fix: handle AssertionError from html.parser on edge-case markup Fix handle AssertionError from html.parser on edge-case markup Apr 27, 2026
@shenxianpeng shenxianpeng merged commit 2caeffe into main Apr 27, 2026
23 checks passed
@shenxianpeng shenxianpeng deleted the fix-4001-html-parser-assertion branch April 27, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant