Skip to content

Commit fceff0e

Browse files
Merge pull request #719 from Sanjays2402/fix/head-style-block-tags
Treat head and style as block-level tags (#331)
2 parents becf394 + 50a3b36 commit fceff0e

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎lib/markdown2.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ def _detab(self, text: str) -> str:
901901
""" % _block_tags_a,
902902
re.X | re.M)
903903

904-
_block_tags_b = 'blockquote|div|dl|fieldset|form|h[1-6]|iframe|math|noscript|ol|p|pre|script|table|ul'
904+
_block_tags_b = 'blockquote|div|dl|fieldset|form|h[1-6]|head|iframe|math|noscript|ol|p|pre|script|style|table|ul'
905905
_block_tags_b += _html5tags
906906

907907
_span_tags = (

‎test/test_markdown2.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,18 @@ def test_russian(self):
272272
'<h2>%s</h2>\n' % ko)
273273
test_russian.tags = ["unicode", "issue3"]
274274

275+
def test_head_and_style_block_tags(self):
276+
# `head` and `style` are block-level, but were missing from the
277+
# liberal block-tag list, so a single-line `<style>...</style>` (or
278+
# `<head>`) got wrapped in a spurious `<p>`.
279+
self._assertMarkdown(
280+
'<style>body { margin-left: 1.25cm; }</style>',
281+
'<style>body { margin-left: 1.25cm; }</style>\n')
282+
self._assertMarkdown(
283+
'<head><meta charset="UTF-8"></head>',
284+
'<head><meta charset="UTF-8"></head>\n')
285+
test_head_and_style_block_tags.tags = ["html", "issue331"]
286+
275287
def test_breaks_and_break_on_newline_together(self):
276288
# `break-on-newline` is an alias for the breaks extra; supplying both
277289
# in the common list form used to raise TypeError during setup.

0 commit comments

Comments
 (0)