summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkernc <kerncece@gmail.com>2022-12-02 14:41:22 +0100
committerGitHub <noreply@github.com>2022-12-02 08:41:22 -0500
commita8ad6fc8ba687736145b5dff3b0c53839d07ef1e (patch)
tree66a1ef8f24db2b7972c0a556eab8de09b96d38dc
parente3604b473f01787e5df0a3fed6c50e3a494c6362 (diff)
downloadpython-markdown-a8ad6fc8ba687736145b5dff3b0c53839d07ef1e.tar.gz
Consider <html> a block-level HTML element (#1309)
-rw-r--r--docs/change_log/index.md1
-rw-r--r--markdown/core.py14
-rw-r--r--markdown/util.py4
3 files changed, 5 insertions, 14 deletions
diff --git a/docs/change_log/index.md b/docs/change_log/index.md
index 6dd57c4..34ca9fe 100644
--- a/docs/change_log/index.md
+++ b/docs/change_log/index.md
@@ -6,6 +6,7 @@ Python-Markdown Change Log
*under development*: version 3.4.1 (a bug-fix release).
* Improve standalone * and _ parsing (#1300).
+* Consider `<html>` HTML tag a block-level element (#1309).
July 15, 2022: version 3.4.1 (a bug-fix release).
diff --git a/markdown/core.py b/markdown/core.py
index f6a171c..c9da4be 100644
--- a/markdown/core.py
+++ b/markdown/core.py
@@ -31,6 +31,7 @@ from .inlinepatterns import build_inlinepatterns
from .postprocessors import build_postprocessors
from .extensions import Extension
from .serializers import to_html_string, to_xhtml_string
+from .util import BLOCK_LEVEL_ELEMENTS
__all__ = ['Markdown', 'markdown', 'markdownFromFile']
@@ -72,18 +73,7 @@ class Markdown:
self.ESCAPED_CHARS = ['\\', '`', '*', '_', '{', '}', '[', ']',
'(', ')', '>', '#', '+', '-', '.', '!']
- self.block_level_elements = [
- # Elements which are invalid to wrap in a `<p>` tag.
- # See https://w3c.github.io/html/grouping-content.html#the-p-element
- 'address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl',
- 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3',
- 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'main', 'menu', 'nav', 'ol',
- 'p', 'pre', 'section', 'table', 'ul',
- # Other elements which Markdown should not be mucking up the contents of.
- 'canvas', 'colgroup', 'dd', 'body', 'dt', 'group', 'iframe', 'li', 'legend',
- 'math', 'map', 'noscript', 'output', 'object', 'option', 'progress', 'script',
- 'style', 'summary', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'video'
- ]
+ self.block_level_elements = BLOCK_LEVEL_ELEMENTS.copy()
self.registeredExtensions = []
self.docType = ""
diff --git a/markdown/util.py b/markdown/util.py
index e6b08e5..9bda07e 100644
--- a/markdown/util.py
+++ b/markdown/util.py
@@ -41,9 +41,9 @@ BLOCK_LEVEL_ELEMENTS = [
'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'main', 'menu', 'nav', 'ol',
'p', 'pre', 'section', 'table', 'ul',
# Other elements which Markdown should not be mucking up the contents of.
- 'canvas', 'colgroup', 'dd', 'body', 'dt', 'group', 'iframe', 'li', 'legend',
+ 'canvas', 'colgroup', 'dd', 'body', 'dt', 'group', 'html', 'iframe', 'li', 'legend',
'math', 'map', 'noscript', 'output', 'object', 'option', 'progress', 'script',
- 'style', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'video'
+ 'style', 'summary', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'video'
]
# Placeholders