Skip to content

Commit

Permalink
Ensure when tag text is None that it is converted to empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser authored Oct 21, 2020
1 parent 6b6cd8b commit 2a883a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/change_log/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Python-Markdown Change Log
Under development: version 3.3.3 (a bug-fix release).

* Unify all block-level tags (#1047).
* Fix issue where some empty elements would have text rendered as `None` when using `md_in_html` (#1049).

Oct 19, 2020: version 3.3.2 (a bug-fix release).

Expand Down
2 changes: 2 additions & 0 deletions markdown/extensions/md_in_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ def parse_element_content(self, element):

else:
# Disable inline parsing for everything else
if element.text is None:
element.text = ''
element.text = util.AtomicString(element.text)
for child in list(element):
self.parse_element_content(child)
Expand Down
18 changes: 18 additions & 0 deletions tests/test_syntax/extensions/test_md_in_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,24 @@ def test_md1_nested_empty_block(self):
)
)

def test_empty_tags(self):
self.assertMarkdownRenders(
self.dedent(
"""
<div markdown="1">
<div></div>
</div>
"""
),
self.dedent(
"""
<div>
<div></div>
</div>
"""
)
)

def test_orphan_end_tag_in_raw_html(self):
self.assertMarkdownRenders(
self.dedent(
Expand Down

0 comments on commit 2a883a2

Please sign in to comment.