Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix html, head and body tags being wrapped in <p> tags (#575) #576

Merged
merged 2 commits into from Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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>