Add bgcolor option

The same color value is used for html.body.style.background-color
and gv.graph.bgcolor to make the diagram fit seamlessly in the HTML
output. "bgcolor" is chosen as option name to avoid the dash in the
CSS name "background-color".
This commit is contained in:
KV 2021-02-23 20:44:40 +01:00
parent 5aac2ba8f3
commit 22f20e2950
3 changed files with 5 additions and 3 deletions

View File

@ -42,6 +42,7 @@ class Metadata:
@dataclass
class Options:
fontname: PlainText = 'arial'
bgcolor: Color = 'WH'
color_mode: ColorMode = 'SHORT'
mini_bom_mode: bool = True

View File

@ -95,7 +95,7 @@ class Harness:
dot.body.append(f'// {APP_URL}')
dot.attr('graph', rankdir='LR',
ranksep='2',
bgcolor='white',
bgcolor=wv_colors.translate_color(self.options.bgcolor, "HEX"),
nodesep='0.33',
fontname=self.options.fontname)
dot.attr('node', shape='record',

View File

@ -5,7 +5,7 @@ from pathlib import Path
from typing import List, Union
import re
from wireviz import __version__, APP_NAME, APP_URL
from wireviz import __version__, APP_NAME, APP_URL, wv_colors
from wireviz.DataClasses import Metadata, Options
from wireviz.wv_helper import flatten2d, open_file_read, open_file_write
@ -16,7 +16,8 @@ def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]],
file.write(' <meta charset="UTF-8">\n')
file.write(f' <meta name="generator" content="{APP_NAME} {__version__} - {APP_URL}">\n')
file.write(f' <title>{metadata.title}</title>\n')
file.write(f'</head><body style="font-family:{options.fontname}">\n')
file.write(f'</head><body style="font-family:{options.fontname};background-color:'
f'{wv_colors.translate_color(options.bgcolor, "HEX")}">\n')
file.write(f'<h1>{metadata.title}</h1>\n')
if metadata.description: