diff --git a/recipe_json_to_html.py b/recipe_json_to_html.py index c218bb9..dfd4faa 100644 --- a/recipe_json_to_html.py +++ b/recipe_json_to_html.py @@ -4,10 +4,13 @@ from anytree.importer import DictImporter from sys import argv -def build_table_depth_first(node, rows, leaf_count=0): +def build_table_depth_first(node, rows=None): + + if rows is None: + rows = [] for child in sorted(node.children, key=lambda x: x.height, reverse=True): - leaf_count = build_table_depth_first(child, rows, leaf_count) + rows = build_table_depth_first(child, rows) colspan = 0 if node.siblings: @@ -17,20 +20,17 @@ def build_table_depth_first(node, rows, leaf_count=0): colspan = max_sibling_height - node.height + 1 if node.is_leaf: - cur_row = leaf_count - rows[cur_row].append(f'
") print("