diff --git a/prosemirror/model/from_dom.py b/prosemirror/model/from_dom.py index 994a2e9..fa5696f 100644 --- a/prosemirror/model/from_dom.py +++ b/prosemirror/model/from_dom.py @@ -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 diff --git a/tests/prosemirror_model/tests/test_dom.py b/tests/prosemirror_model/tests/test_dom.py index c06b529..481ef6e 100644 --- a/tests/prosemirror_model/tests/test_dom.py +++ b/tests/prosemirror_model/tests/test_dom.py @@ -178,6 +178,25 @@ def test_html_is_escaped(): ], }, ), + ( + "Indented HTML", + """ +
+

+ test +

+
+ """, + { + "type": "doc", + "content": [ + { + "type": "paragraph", + "content": [{"type": "text", "text": "test"}], + }, + ], + }, + ), ( "Styled(marks) nodes pt1", """

test some bolded text

""",