fix: treat custom element names as block-level HTML - #1624
fix: treat custom element names as block-level HTML#1624BetterAndBetterII wants to merge 1 commit into
Conversation
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
|
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. |
Summary
Custom element names are required to contain a hyphen.
is_block_level()andmd_in_htmlpreviously only recognized a fixed list of block tags, so a standalone<a-b>…</a-b>was wrapped in<p>and themarkdownattribute on those tags was ignored.Treat any tag name that contains a hyphen as block-level (same treatment as
<div>). Inner Markdown still requires themarkdown/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_inlinepython -m unittest discover tests)Fixes #1246