diff --git a/src/wireviz/wv_bom.py b/src/wireviz/wv_bom.py index 17f090a..cb9a76a 100644 --- a/src/wireviz/wv_bom.py +++ b/src/wireviz/wv_bom.py @@ -145,25 +145,18 @@ def component_table_entry( mpn: Optional[str] = None, ) -> str: """Return a diagram node table row string with an additional component.""" - output = f'{qty}' - if unit: - output += f' {unit}' - output += f' x {type}' - # print an extra line with part and manufacturer information if provided manufacturer_str = manufacturer_info_field(manufacturer, mpn) - if pn or manufacturer_str: - output += '
' - if pn: - output += f'P/N: {pn}' - if manufacturer_str: - output += ', ' - if manufacturer_str: - output += manufacturer_str - output = html_line_breaks(output) + output = (f'{qty}' + + (f' {unit}' if unit else '') + + f' x {type}' + + ('
' if pn or manufacturer_str else '') + + (f'P/N: {pn}' if pn else '') + + (', ' if pn and manufacturer_str else '') + + (manufacturer_str or '')) # format the above output as left aligned text in a single visible cell # indent is set to two to match the indent in the generated html table return f''' - +
{output}{html_line_breaks(output)}
''' def manufacturer_info_field(manufacturer: Optional[str], mpn: Optional[str]) -> Optional[str]: