Skip to content

Honor tags added to block_level_elements after md_in_html loads - #1629

Merged
waylan merged 1 commit into
Python-Markdown:masterfrom
gyanu2507:md-in-html-live-block-tags
Sep 6, 2026
Merged

Honor tags added to block_level_elements after md_in_html loads#1629
waylan merged 1 commit into
Python-Markdown:masterfrom
gyanu2507:md-in-html-live-block-tags

Conversation

@gyanu2507

@gyanu2507 gyanu2507 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

md_in_html copied Markdown.block_level_elements when the extractor was constructed. Tags registered later with md.block_level_elements.append('a-b') were therefore ignored, so custom elements never got block-level treatment or markdown="1" parsing.

The extractor now reads the live list. That is the change discussed in #1246 (not treating every hyphenated name as a block tag).

Test plan

  • python3 -m unittest tests.test_syntax.extensions.test_md_in_html (198 tests)

Fixes #1246

The extension copied Markdown.block_level_elements at init, so
md.block_level_elements.append() after construction was ignored.
Read the live list instead.

Fixes Python-Markdown#1246

@waylan waylan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good! Unfortunately, you deleted the PR template and now we don’t have a disclosure statement from you about AI use, if any. Please add a comment.

@waylan waylan added extension Related to one or more of the included extensions. more-info-needed More information needs to be provided. approved The pull request is ready to be merged. labels Sep 5, 2026
@gyanu2507

gyanu2507 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Sorry about dropping the template.

AI Assistance Disclosure

  • If AI tools were used, I have disclosed which ones, and fully reviewed and verified their output.

I used an LLM coding assistant to help draft the change. I reviewed the diff, followed the approach discussed in #1246 (read the live block_level_elements list rather than treating every hyphenated name as a block tag), and ran python3 -m unittest tests.test_syntax.extensions.test_md_in_html.

@gyanu2507
gyanu2507 requested a review from waylan September 6, 2026 05:25
@waylan
waylan merged commit c74b8d8 into Python-Markdown:master Sep 6, 2026
14 checks passed
@waylan waylan removed the more-info-needed More information needs to be provided. label Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved The pull request is ready to be merged. extension Related to one or more of the included extensions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extension md_in_html does not recognize tags with hyphens

2 participants