diff --git a/src/wireviz/wv_gv_html.py b/src/wireviz/wv_gv_html.py index 812b9a0..c7cd6ec 100644 --- a/src/wireviz/wv_gv_html.py +++ b/src/wireviz/wv_gv_html.py @@ -77,19 +77,15 @@ def gv_node_component( line_notes, ] - tbl = nested_table(lines) - - tbl.update_attribs(bgcolor=translate_color(component.bgcolor, "HEX")) - - if isinstance(component, Connector) and harness_options.bgcolor_connector: - tbl.update_attribs( - bgcolor=translate_color(harness_options.bgcolor_connector, "HEX") - ) + if component.bgcolor: + tbl_bgcolor = translate_color(component.bgcolor, "HEX") + elif isinstance(component, Connector) and harness_options.bgcolor_connector: + tbl_bgcolor = translate_color(harness_options.bgcolor_connector, "HEX") elif isinstance(component, Cable) and harness_options.bgcolor_cable: - tbl.update_attribs( - bgcolor=translate_color(harness_options.bgcolor_cable, "HEX") - ) + tbl_bgcolor = translate_color(harness_options.bgcolor_cable, "HEX") + tbl = nested_table(lines) + tbl.update_attribs(bgcolor=tbl_bgcolor) return tbl @@ -111,6 +107,7 @@ def make_list_of_cells(inp) -> List[Td]: def nested_table(lines: List[Td]) -> Table: cell_lists = [make_list_of_cells(line) for line in lines] rows = [] + for lst in cell_lists: if len(lst) == 0: continue # no cells in list @@ -132,10 +129,10 @@ def nested_table(lines: List[Td]) -> Table: Tr(cells), border=0, cellspacing=0, cellpadding=3, cellborder=1 ) rows.append(Tr(Td(inner_table))) + if len(rows) == 0: # create dummy row to avoid GraphViz errors due to empty