From a8ad6fc8ba687736145b5dff3b0c53839d07ef1e Mon Sep 17 00:00:00 2001 From: kernc Date: Fri, 2 Dec 2022 14:41:22 +0100 Subject: Consider a block-level HTML element (#1309) --- docs/change_log/index.md | 1 + markdown/core.py | 14 ++------------ markdown/util.py | 4 ++-- 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 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 `

` 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 -- cgit v1.2.1