Skip to content

Commit d1ed480

Browse files
committed
Ensure <summary> tags are parsed correctly.
Fixes #1079.
1 parent 7cff3bd commit d1ed480

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

docs/change_log/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Under development: version 3.3.5 (a bug-fix release).
1010
* Re-use compiled regex for block level checks (#1169).
1111
* Don't process shebangs in fenced code blocks when using CodeHilite (#1156).
1212
* Improve email address validation for Automatic Links (#1165).
13+
* Ensure `<summary>` tags are parsed correctly (#1079).
1314

1415
Feb 24, 2021: version 3.3.4 (a bug-fix release).
1516

markdown/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __init__(self, **kwargs):
8282
# Other elements which Markdown should not be mucking up the contents of.
8383
'canvas', 'colgroup', 'dd', 'body', 'dt', 'group', 'iframe', 'li', 'legend',
8484
'math', 'map', 'noscript', 'output', 'object', 'option', 'progress', 'script',
85-
'style', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'video'
85+
'style', 'summary', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'video'
8686
]
8787

8888
self.registeredExtensions = []

markdown/extensions/md_in_html.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ def __init__(self, md, *args, **kwargs):
3333
self.block_level_tags = set(md.block_level_elements.copy())
3434
# Block-level tags in which the content only gets span level parsing
3535
self.span_tags = set(
36-
['address', 'dd', 'dt', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'legend', 'li', 'p', 'td', 'th']
36+
['address', 'dd', 'dt', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'legend', 'li', 'p', 'summary', 'td', 'th']
3737
)
3838
# Block-level tags which never get their content parsed.
3939
self.raw_tags = set(['canvas', 'math', 'option', 'pre', 'script', 'style', 'textarea'])
40-
# Block-level tags in which the content gets parsed as blocks
40+
4141
super().__init__(md, *args, **kwargs)
4242

43+
# Block-level tags in which the content gets parsed as blocks
4344
self.block_tags = set(self.block_level_tags) - (self.span_tags | self.raw_tags | self.empty_tags)
4445
self.span_and_blocks_tags = self.block_tags | self.span_tags
4546

tests/test_syntax/extensions/test_md_in_html.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,26 @@ def test_md1_div_multi_nest(self):
283283
)
284284
)
285285

286+
def text_md1_details(self):
287+
self.assertMarkdownRenders(
288+
self.dedent(
289+
"""
290+
<details markdown="1">
291+
<summary>Click to expand</summary>
292+
*foo*
293+
</details>
294+
"""
295+
),
296+
self.dedent(
297+
"""
298+
<details>
299+
<summary>Click to expand</summary>
300+
<p><em>foo</em></p>
301+
</details>
302+
"""
303+
)
304+
)
305+
286306
def test_md1_mix(self):
287307
self.assertMarkdownRenders(
288308
self.dedent(

0 commit comments

Comments
 (0)