From 7fbbda70ad76a0662fe6646a1913da12472a514a Mon Sep 17 00:00:00 2001 From: Crozzers Date: Sat, 20 Apr 2024 10:25:20 +0100 Subject: [PATCH 1/2] Fix #575 by adding `html`, `head` and `body` tags to block tags regex --- lib/markdown2.py | 4 ++-- test/tm-cases/block_tags.html | 23 +++++++++++++++++++++++ test/tm-cases/block_tags.text | 23 +++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 test/tm-cases/block_tags.html create mode 100644 test/tm-cases/block_tags.text diff --git a/lib/markdown2.py b/lib/markdown2.py index 42a1518c..86876ab5 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -814,7 +814,7 @@ def _detab(self, text): # _block_tags_b. This way html5 tags are easy to keep track of. _html5tags = '|article|aside|header|hgroup|footer|nav|section|figure|figcaption' - _block_tags_a = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|style' + _block_tags_a = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|style|html|head|body' _block_tags_a += _html5tags _strict_tag_block_re = re.compile(r""" @@ -2773,7 +2773,7 @@ class Latex(Extra): _single_dollar_re = re.compile(r'(?(.*?)", re.DOTALL) # Wraped in
     _triple_re = re.compile(r'```(.*?)```', re.DOTALL) # Wrapped in a code block ```
diff --git a/test/tm-cases/block_tags.html b/test/tm-cases/block_tags.html
new file mode 100644
index 00000000..12ced98a
--- /dev/null
+++ b/test/tm-cases/block_tags.html
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+content here
+
+ there is supposed to be an image here
+
+Now some bullets:
+
+  * one
+  * two
+
+
+
+
+
diff --git a/test/tm-cases/block_tags.text b/test/tm-cases/block_tags.text
new file mode 100644
index 00000000..12ced98a
--- /dev/null
+++ b/test/tm-cases/block_tags.text
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+content here
+
+ there is supposed to be an image here
+
+Now some bullets:
+
+  * one
+  * two
+
+
+
+
+

From 0e51afb03973a0a6b20751fc38d4d3f0696b8ea1 Mon Sep 17 00:00:00 2001
From: Crozzers 
Date: Sat, 20 Apr 2024 10:32:53 +0100
Subject: [PATCH 2/2] Update changelog

---
 CHANGES.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CHANGES.md b/CHANGES.md
index 7049ab49..a47d7ebb 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -9,6 +9,7 @@
 - [pull #570] Fix syntax warnings in test suite
 - [pull #572] Process inline tags as HTML blocks when they span multiple lines (#571)
 - [pull #573] Add new LaTeX Extra
+- [pull #576] Fix `html`, `head` and `body` tags being wrapped in `

` tags (#575) ## python-markdown2 2.4.13