Skip to content

fix: treat custom element names as block-level HTML - #1624

Closed
BetterAndBetterII wants to merge 1 commit into
Python-Markdown:masterfrom
BetterAndBetterII:fix/md-in-html-custom-elements
Closed

fix: treat custom element names as block-level HTML#1624
BetterAndBetterII wants to merge 1 commit into
Python-Markdown:masterfrom
BetterAndBetterII:fix/md-in-html-custom-elements

Conversation

@BetterAndBetterII

Copy link
Copy Markdown

Summary

Custom element names are required to contain a hyphen. is_block_level() and md_in_html previously only recognized a fixed list of block tags, so a standalone <a-b>…</a-b> was wrapped in <p> and the markdown attribute on those tags was ignored.

Treat any tag name that contains a hyphen as block-level (same treatment as <div>). Inner Markdown still requires the markdown / markdown="1" attribute. Inline use mid-paragraph stays span-level.

Test plan

  • python -m unittest tests.test_syntax.blocks.test_html_blocks.TestHTMLBlocks.test_raw_custom_element tests.test_syntax.extensions.test_md_in_html.TestMdInHTML.test_custom_element_markdown_attr tests.test_syntax.extensions.test_md_in_html.TestMdInHTML.test_custom_element_md1 tests.test_syntax.extensions.test_md_in_html.TestMdInHTML.test_custom_element_inline
  • Full suite previously green under grok (python -m unittest discover tests)

Fixes #1246

Custom elements must contain a hyphen. Treat those tag names like
other block-level elements so md_in_html and raw HTML blocks no
longer wrap them in <p>.

Fixes Python-Markdown#1246
@waylan

waylan commented Aug 28, 2026

Copy link
Copy Markdown
Member

If I am not mistaken, this is not the fix suggested in #1246. This accepts any tag name which contains a hyphen, whereas the fix discussed in #1246 was to allow the user to add specific tags and only those tags would be recognized as block-level. As noted, users can already add tags to the list of recognized tags. However, due to a bug, the md-in-html extension does not recognize them.

Note that, as documented, all first-party extensions have entered maintenance mode and are no longer accepting new features. Adding support for all hyphenated tags would be a new feature. However, fixing the bug which prevents the extension from recognizing a user provided tag (regardless of whether it was a web-component) would not be a new feature, but a bug fix (as that is how it was intended to work from the beginning). Therefore, that is the only fix we will accept. Anything more than that would require a new or forked third-part extension to implement.

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.

Extension md_in_html does not recognize tags with hyphens

2 participants