Skip to content

Commit

Permalink
Merge pull request #315 from mattmikolay/main
Browse files Browse the repository at this point in the history
Fix handling of indented HTML in DOMParser
  • Loading branch information
p7g authored Aug 20, 2024
2 parents 34c9614 + 8d4bd0f commit 4754bf6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion prosemirror/model/from_dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def add_text_node(self, dom_: DOMNode) -> None:
re.search(r"^[ \t\r\n\u000c]", value) is not None
and self.open == len(self.nodes) - 1
):
node_before = top.content[-1]
node_before = top.content[-1] if top.content else None
dom_node_before = dom_.getprevious()
if (
node_before is None
Expand Down
19 changes: 19 additions & 0 deletions tests/prosemirror_model/tests/test_dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,25 @@ def test_html_is_escaped():
],
},
),
(
"Indented HTML",
"""
<div>
<p>
test
</p>
</div>
""",
{
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [{"type": "text", "text": "test"}],
},
],
},
),
(
"Styled(marks) nodes pt1",
"""<div><p>test <strong>some bolded text</strong></p></div>""",
Expand Down

0 comments on commit 4754bf6

Please sign in to comment.