Skip to content

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

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

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
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

1 participant