From ba6d5f4255eb5a566fca8b1d0829ecc50836b0bd Mon Sep 17 00:00:00 2001 From: gamerdonkey Date: Fri, 29 Aug 2025 01:01:34 -0500 Subject: [PATCH] Table layout improvements. --- output_html.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/output_html.py b/output_html.py index 90d62bb..0e980f9 100644 --- a/output_html.py +++ b/output_html.py @@ -8,14 +8,26 @@ def build_rows_depth_first(node, rows, leaf_count=0): for child in sorted(node.children, key=lambda x: x.height, reverse=True): leaf_count = build_rows_depth_first(child, rows, leaf_count) + colspan = 0 + if node.siblings: + max_sibling_height = max([s.height for s in node.siblings]) + + if max_sibling_height > node.height: + colspan = max_sibling_height - node.height + 1 + if node.is_leaf: cur_row = leaf_count - rows[cur_row].append(f'{node.name}') + rows[cur_row].append(f'{node.name}') + + if colspan > 1: + rows[cur_row].append(f'') + leaf_count += 1 + else: child_leaves = len(node.leaves) cur_row = leaf_count - child_leaves - rows[cur_row].append(f'{node.name}') + rows[cur_row].append(f"{node.name}") return leaf_count @@ -34,8 +46,12 @@ for i in range(len(root.leaves)): build_rows_depth_first(root, output_rows) +print("") + for row in output_rows: print("") for cell in row: print(f" {cell}") print("") + +print("
")