Resolves issue #97

This commit is contained in:
Greg Johnston 2022-11-21 07:30:13 -05:00
parent 9f1b27ad26
commit d0c6319a72

View file

@ -302,7 +302,7 @@ fn insert_expression(
Child::Nodes(new_nodes.to_vec()) Child::Nodes(new_nodes.to_vec())
} }
} else { } else {
clean_children(&parent, Child::Null, before, None); clean_children(&parent, current, before, None);
append_nodes(parent, new_nodes.to_vec(), before.as_some_node().cloned()); append_nodes(parent, new_nodes.to_vec(), before.as_some_node().cloned());
Child::Nodes(new_nodes.to_vec()) Child::Nodes(new_nodes.to_vec())
} }
@ -427,7 +427,10 @@ fn clean_children(
match current { match current {
Child::Null => Child::Node(insert_before(parent, &node, marker.as_some_node())), Child::Null => Child::Node(insert_before(parent, &node, marker.as_some_node())),
Child::Text(_) => Child::Node(insert_before(parent, &node, marker.as_some_node())), Child::Text(_) => Child::Node(insert_before(parent, &node, marker.as_some_node())),
Child::Node(_) => Child::Node(insert_before(parent, &node, marker.as_some_node())), Child::Node(current) => {
replace_child(parent, &node, &current);
Child::Node(node)
}
Child::Nodes(nodes) => { Child::Nodes(nodes) => {
if nodes.is_empty() { if nodes.is_empty() {
Child::Node(insert_before(parent, &node, marker.as_some_node())) Child::Node(insert_before(parent, &node, marker.as_some_node()))