From 50a3b368eb589b8994b833dcf8d3db336e2b258f Mon Sep 17 00:00:00 2001 From: Sanjay Santhanam <51058514+Sanjays2402@users.noreply.github.com> Date: Thu, 30 Jul 2026 21:44:29 -0700 Subject: [PATCH] Treat head and style as block-level tags (#331) `
` and `` or `...` therefore never got hashed as an HTML block and was wrapped in a spurious ``. Added both tags to `_block_tags_b`, matching how the sibling block tags (div, table, script, pre) are declared in both lists. Added a regression test in test/test_markdown2.py alongside the other DirectTestCase cases. --- lib/markdown2.py | 2 +- test/test_markdown2.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/markdown2.py b/lib/markdown2.py index a330761a..e9025aa3 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -901,7 +901,7 @@ def _detab(self, text: str) -> str: """ % _block_tags_a, re.X | re.M) - _block_tags_b = 'blockquote|div|dl|fieldset|form|h[1-6]|iframe|math|noscript|ol|p|pre|script|table|ul' + _block_tags_b = 'blockquote|div|dl|fieldset|form|h[1-6]|head|iframe|math|noscript|ol|p|pre|script|style|table|ul' _block_tags_b += _html5tags _span_tags = ( diff --git a/test/test_markdown2.py b/test/test_markdown2.py index 8cdcef61..0dd22ad9 100755 --- a/test/test_markdown2.py +++ b/test/test_markdown2.py @@ -272,6 +272,18 @@ def test_russian(self): '
`. + self._assertMarkdown( + '', + '\n') + self._assertMarkdown( + '
', + '\n') + test_head_and_style_block_tags.tags = ["html", "issue331"] + def test_breaks_and_break_on_newline_together(self): # `break-on-newline` is an alias for the breaks extra; supplying both # in the common list form used to raise TypeError during setup.