Skip to content

Commit a8ad6fc

Browse files
authored
Consider <html> a block-level HTML element (#1309)
1 parent e3604b4 commit a8ad6fc

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

docs/change_log/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Python-Markdown Change Log
66
*under development*: version 3.4.1 (a bug-fix release).
77

88
* Improve standalone * and _ parsing (#1300).
9+
* Consider `<html>` HTML tag a block-level element (#1309).
910

1011
July 15, 2022: version 3.4.1 (a bug-fix release).
1112

markdown/core.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .postprocessors import build_postprocessors
3232
from .extensions import Extension
3333
from .serializers import to_html_string, to_xhtml_string
34+
from .util import BLOCK_LEVEL_ELEMENTS
3435

3536
__all__ = ['Markdown', 'markdown', 'markdownFromFile']
3637

@@ -72,18 +73,7 @@ def __init__(self, **kwargs):
7273
self.ESCAPED_CHARS = ['\\', '`', '*', '_', '{', '}', '[', ']',
7374
'(', ')', '>', '#', '+', '-', '.', '!']
7475

75-
self.block_level_elements = [
76-
# Elements which are invalid to wrap in a `<p>` tag.
77-
# See https://w3c.github.io/html/grouping-content.html#the-p-element
78-
'address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl',
79-
'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3',
80-
'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'main', 'menu', 'nav', 'ol',
81-
'p', 'pre', 'section', 'table', 'ul',
82-
# Other elements which Markdown should not be mucking up the contents of.
83-
'canvas', 'colgroup', 'dd', 'body', 'dt', 'group', 'iframe', 'li', 'legend',
84-
'math', 'map', 'noscript', 'output', 'object', 'option', 'progress', 'script',
85-
'style', 'summary', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'video'
86-
]
76+
self.block_level_elements = BLOCK_LEVEL_ELEMENTS.copy()
8777

8878
self.registeredExtensions = []
8979
self.docType = ""

markdown/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'main', 'menu', 'nav', 'ol',
4242
'p', 'pre', 'section', 'table', 'ul',
4343
# Other elements which Markdown should not be mucking up the contents of.
44-
'canvas', 'colgroup', 'dd', 'body', 'dt', 'group', 'iframe', 'li', 'legend',
44+
'canvas', 'colgroup', 'dd', 'body', 'dt', 'group', 'html', 'iframe', 'li', 'legend',
4545
'math', 'map', 'noscript', 'output', 'object', 'option', 'progress', 'script',
46-
'style', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'video'
46+
'style', 'summary', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'video'
4747
]
4848

4949
# Placeholders

0 commit comments

Comments
 (0)