Example #1
0
def display_simple_texttype_node(text_node: Node = None) -> str:
    # Currently, this handles simple cases with paras only (paras may be contained in sections)
    if not text_node:
        return ''
    if text_node.content:
        return text_node.content
    text = ''
    para_nodes = []
    text_node.find_all_descendants(names.PARA, para_nodes)
    for para_node in para_nodes:
        if para_node.content:
            text += f'{para_node.content}\n'
    return text.replace('&lt;', '<').replace('&gt;', '>')
Example #2
0
def expand(node: Node):
    references = list()
    node.find_all_descendants(names.REFERENCES, references)
    ids = _register_ids(node)
    for reference in references:
        if reference.content not in ids:
            msg = f"ID not found for REFERENCE '{reference}'"
            raise ValueError(msg)
        source_node = ids[reference.content]
        destination_node = reference.parent
        destination_node.remove_child(reference)
        Node.delete_node_instance(reference.id)
        for source_child in source_node.children:
            source_child_copy = source_child.copy()
            destination_node.add_child(source_child_copy)