Skip to content

Commit b2a512d

Browse files
Merge pull request #576 from Crozzers/fix-575
Fix `html`, `head` and `body` tags being wrapped in `<p>` tags (#575)
2 parents ac7fd19 + 0e51afb commit b2a512d

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [pull #570] Fix syntax warnings in test suite
1010
- [pull #572] Process inline tags as HTML blocks when they span multiple lines (#571)
1111
- [pull #573] Add new LaTeX Extra
12+
- [pull #576] Fix `html`, `head` and `body` tags being wrapped in `<p>` tags (#575)
1213

1314

1415
## python-markdown2 2.4.13

lib/markdown2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ def _detab(self, text):
814814
# _block_tags_b. This way html5 tags are easy to keep track of.
815815
_html5tags = '|article|aside|header|hgroup|footer|nav|section|figure|figcaption'
816816

817-
_block_tags_a = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|style'
817+
_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'
818818
_block_tags_a += _html5tags
819819

820820
_strict_tag_block_re = re.compile(r"""
@@ -2773,7 +2773,7 @@ class Latex(Extra):
27732773

27742774
_single_dollar_re = re.compile(r'(?<!\$)\$(?!\$)(.*?)\$')
27752775
_double_dollar_re = re.compile(r'\$\$(.*?)\$\$', re.DOTALL)
2776-
2776+
27772777
# Ways to escape
27782778
_pre_code_block_re = re.compile(r"<pre>(.*?)</pre>", re.DOTALL) # Wraped in <pre>
27792779
_triple_re = re.compile(r'```(.*?)```', re.DOTALL) # Wrapped in a code block ```

test/tm-cases/block_tags.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<html>
2+
3+
<!-- Comment please ignore -->
4+
5+
<!-- Multi
6+
line Comment
7+
please ignore -->
8+
9+
10+
<body>
11+
content here
12+
13+
<img src="some_img.jpg" alt="there is supposed to be an image here" width="500" height="600">
14+
15+
Now some bullets:
16+
17+
* one
18+
* two
19+
20+
</body>
21+
22+
23+
</html>

test/tm-cases/block_tags.text

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<html>
2+
3+
<!-- Comment please ignore -->
4+
5+
<!-- Multi
6+
line Comment
7+
please ignore -->
8+
9+
10+
<body>
11+
content here
12+
13+
<img src="some_img.jpg" alt="there is supposed to be an image here" width="500" height="600">
14+
15+
Now some bullets:
16+
17+
* one
18+
* two
19+
20+
</body>
21+
22+
23+
</html>

0 commit comments

Comments
 (0)