Skip to content

Commit

Permalink
Ensure <summary> tags are parsed correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
waylan committed Nov 3, 2021
1 parent 7cff3bd commit d1ed480
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/change_log/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
2 changes: 1 addition & 1 deletion markdown/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self, **kwargs):
# 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 = []
Expand Down
5 changes: 3 additions & 2 deletions markdown/extensions/md_in_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ def __init__(self, md, *args, **kwargs):
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

Expand Down
20 changes: 20 additions & 0 deletions tests/test_syntax/extensions/test_md_in_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,26 @@ def test_md1_div_multi_nest(self):
)
)

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(
Expand Down

0 comments on commit d1ed480

Please sign in to comment.