Skip to content

Commit

Permalink
Merge pull request #576 from Crozzers/fix-575
Browse files Browse the repository at this point in the history
Fix `html`, `head` and `body` tags being wrapped in `<p>` tags (#575)
  • Loading branch information
nicholasserra committed Apr 22, 2024
2 parents ac7fd19 + 0e51afb commit b2a512d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -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 `<p>` tags (#575)


## python-markdown2 2.4.13
Expand Down
4 changes: 2 additions & 2 deletions lib/markdown2.py
Expand Up @@ -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"""
Expand Down Expand Up @@ -2773,7 +2773,7 @@ class Latex(Extra):

_single_dollar_re = re.compile(r'(?<!\$)\$(?!\$)(.*?)\$')
_double_dollar_re = re.compile(r'\$\$(.*?)\$\$', re.DOTALL)

# Ways to escape
_pre_code_block_re = re.compile(r"<pre>(.*?)</pre>", re.DOTALL) # Wraped in <pre>
_triple_re = re.compile(r'```(.*?)```', re.DOTALL) # Wrapped in a code block ```
Expand Down
23 changes: 23 additions & 0 deletions test/tm-cases/block_tags.html
@@ -0,0 +1,23 @@
<html>

<!-- Comment please ignore -->

<!-- Multi
line Comment
please ignore -->


<body>
content here

<img src="some_img.jpg" alt="there is supposed to be an image here" width="500" height="600">

Now some bullets:

* one
* two

</body>


</html>
23 changes: 23 additions & 0 deletions test/tm-cases/block_tags.text
@@ -0,0 +1,23 @@
<html>

<!-- Comment please ignore -->

<!-- Multi
line Comment
please ignore -->


<body>
content here

<img src="some_img.jpg" alt="there is supposed to be an image here" width="500" height="600">

Now some bullets:

* one
* two

</body>


</html>

0 comments on commit b2a512d

Please sign in to comment.