diff options
author | Waylan Limberg <waylan.limberg@icloud.com> | 2021-11-03 11:23:05 -0400 |
---|---|---|
committer | Waylan Limberg <waylan.limberg@icloud.com> | 2021-11-03 11:28:06 -0400 |
commit | d1ed480d474e84895749bca1f9c15ea9a0f3ad6a (patch) | |
tree | 59987b2bf3a78c010d9bf95bdfd22dcb9c156bc9 | |
parent | 7cff3bd5af4a3ebea608b9fc7c48327d67147db0 (diff) | |
download | python-markdown-d1ed480d474e84895749bca1f9c15ea9a0f3ad6a.tar.gz |
Ensure <summary> tags are parsed correctly.
Fixes #1079.
-rw-r--r-- | docs/change_log/index.md | 1 | ||||
-rw-r--r-- | markdown/core.py | 2 | ||||
-rw-r--r-- | markdown/extensions/md_in_html.py | 5 | ||||
-rw-r--r-- | tests/test_syntax/extensions/test_md_in_html.py | 20 |
4 files changed, 25 insertions, 3 deletions
diff --git a/docs/change_log/index.md b/docs/change_log/index.md index 914cd0b..9700832 100644 --- a/docs/change_log/index.md +++ b/docs/change_log/index.md @@ -10,6 +10,7 @@ Under development: version 3.3.5 (a bug-fix release). * Re-use compiled regex for block level checks (#1169). * Don't process shebangs in fenced code blocks when using CodeHilite (#1156). * Improve email address validation for Automatic Links (#1165). +* Ensure `<summary>` tags are parsed correctly (#1079). Feb 24, 2021: version 3.3.4 (a bug-fix release). diff --git a/markdown/core.py b/markdown/core.py index 2f7f2d5..d8c8196 100644 --- a/markdown/core.py +++ b/markdown/core.py @@ -82,7 +82,7 @@ class Markdown: # 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', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'video' + 'style', 'summary', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'video' ] self.registeredExtensions = [] diff --git a/markdown/extensions/md_in_html.py b/markdown/extensions/md_in_html.py index 86cf00d..81cc15c 100644 --- a/markdown/extensions/md_in_html.py +++ b/markdown/extensions/md_in_html.py @@ -33,13 +33,14 @@ class HTMLExtractorExtra(HTMLExtractor): self.block_level_tags = set(md.block_level_elements.copy()) # Block-level tags in which the content only gets span level parsing self.span_tags = set( - ['address', 'dd', 'dt', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'legend', 'li', 'p', 'td', 'th'] + ['address', 'dd', 'dt', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'legend', 'li', 'p', 'summary', 'td', 'th'] ) # Block-level tags which never get their content parsed. self.raw_tags = set(['canvas', 'math', 'option', 'pre', 'script', 'style', 'textarea']) - # Block-level tags in which the content gets parsed as blocks + super().__init__(md, *args, **kwargs) + # Block-level tags in which the content gets parsed as blocks self.block_tags = set(self.block_level_tags) - (self.span_tags | self.raw_tags | self.empty_tags) self.span_and_blocks_tags = self.block_tags | self.span_tags diff --git a/tests/test_syntax/extensions/test_md_in_html.py b/tests/test_syntax/extensions/test_md_in_html.py index 8655607..fc9be7c 100644 --- a/tests/test_syntax/extensions/test_md_in_html.py +++ b/tests/test_syntax/extensions/test_md_in_html.py @@ -283,6 +283,26 @@ class TestMdInHTML(TestCase): ) ) + def text_md1_details(self): + self.assertMarkdownRenders( + self.dedent( + """ + <details markdown="1"> + <summary>Click to expand</summary> + *foo* + </details> + """ + ), + self.dedent( + """ + <details> + <summary>Click to expand</summary> + <p><em>foo</em></p> + </details> + """ + ) + ) + def test_md1_mix(self): self.assertMarkdownRenders( self.dedent( |