diff --git a/scripts/generate.py b/scripts/generate.py index 086e7a5..a42a607 100644 --- a/scripts/generate.py +++ b/scripts/generate.py @@ -232,15 +232,28 @@ def main(src_top, dest_top): logging.info("Updated all in {:.2f}s".format(time.time() - t0)) -def print_tree(tree, indentation=0): +def print_tree(tree, indentation=0, headline=None): + # if headline and headline.id != INDEX_ID: + # return return for element in tree: - print(" " * indentation + "- " + str(type(element))) if "children" in dir(element): if len(element.children) > 0: - print_tree(element.children, indentation + 1) + print_element(element.children, indentation + 1, headline) print() + elif "content" in dir(element): + for content in element.content: + print_element(content, indentation + 1, headline) + +def print_element(element, indentation, headline): + if isinstance(element, org_rw.Link): + print(" " * indentation, "Link:", element.get_raw()) + elif isinstance(element, str): + print(" " * indentation, "{" + element + "}", type(element)) + else: + print_tree(element, indentation, headline) + def render_property_drawer(element, acc): pass @@ -334,7 +347,7 @@ def render(headline, doc, headlineLevel): except: logging.error("Error generating DOM for {}".format(doc.path)) raise - print_tree(dom) + print_tree(dom, indentation=2, headline=headline) content = [] render_tree(dom, content)