Commit 1439eeed authored by di68kap's avatar di68kap
Browse files

- Fehlerkorrektur

parent a7a402d2
......@@ -93,7 +93,7 @@ from DHParser import logging, is_filename, load_if_file, \\
Node, TransformationFunc, TransformationDict, transformation_factory, traverse, \\
remove_children_if, move_adjacent, normalize_whitespace, is_anonymous, matches_re, \\
reduce_single_child, replace_by_single_child, replace_or_reduce, remove_whitespace, \\
remove_empty, remove_tokens, flatten, is_insignificant_whitespace, \\
replace_by_children, remove_empty, remove_tokens, flatten, is_insignificant_whitespace, \\
collapse, collapse_if, replace_content, WHITESPACE_PTYPE, TOKEN_PTYPE, \\
remove_nodes, remove_content, remove_brackets, change_tag_name, remove_anonymous_tokens, \\
keep_children, is_one_of, not_one_of, has_content, apply_if, remove_first, remove_last, \\
......@@ -631,11 +631,15 @@ def replace_by_single_child(context: List[Node]):
def replace_by_children(context: List[Node]):
Eliminates the last node in the context by replacing it with its children.
The attributes of this node will be dropped.
The attributes of this node will be dropped. In case the last node is
the root-note (i.e. len(context) == 1), it will not be eliminated.
parent = context[-2]
except IndexError:
node = context[-1]
assert node.children
parent = context[-2]
result = parent.result
i = result.index(node)
parent.result = result[:i] + node.children + result[i + 1:]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment