From 2a62dae9eec5fce017ce17335b154d6632753856 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Thu, 23 Sep 2021 16:20:59 +0200 Subject: [PATCH] Resolve edge case of empty HTML tables --- src/wireviz/wv_gv_html.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wireviz/wv_gv_html.py b/src/wireviz/wv_gv_html.py index 0b843db..ff8b4ea 100644 --- a/src/wireviz/wv_gv_html.py +++ b/src/wireviz/wv_gv_html.py @@ -14,6 +14,8 @@ def nested_html_table(rows: List[Union[str, List[Optional[str]], None]], table_a # attributes in any leading inside a list are injected into to the preceeding tag html = [] html.append(f'') + + num_rows = 0 for row in rows: if isinstance(row, List): if len(row) > 0 and any(row): @@ -25,10 +27,14 @@ def nested_html_table(rows: List[Union[str, List[Optional[str]], None]], table_a html.append(f' '.replace('>
{cell}
') html.append(' ') + num_rows = num_rows + 1 elif row is not None: html.append(' ') html.append(f' {row}') html.append(' ') + num_rows = num_rows + 1 + if num_rows == 0: # empty table + html.append('') # generate empty cell to avoid GraphViz errors html.append('') return html