Allow line breaks in generic metadata

This commit is contained in:
Daniel Rojas 2021-03-28 13:20:06 +02:00
parent 1a41faf187
commit f424ea541e

View File

@ -74,13 +74,13 @@ def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]],
# fill out other generic metadata # fill out other generic metadata
for item, contents in metadata.items(): for item, contents in metadata.items():
if isinstance(contents, (str, int, float)): if isinstance(contents, (str, int, float)):
html = html.replace(f'<!-- %{item}% -->', contents) html = html.replace(f'<!-- %{item}% -->', html_line_breaks(contents))
elif isinstance(contents, Dict): # useful for authors, revisions elif isinstance(contents, Dict): # useful for authors, revisions
for index, (category, entry) in enumerate(contents.items()): for index, (category, entry) in enumerate(contents.items()):
if isinstance(entry, Dict): if isinstance(entry, Dict):
html = html.replace(f'<!-- %{item}_{index+1}% -->', str(category)) html = html.replace(f'<!-- %{item}_{index+1}% -->', str(category))
for entry_key, entry_value in entry.items(): for entry_key, entry_value in entry.items():
html = html.replace(f'<!-- %{item}_{index+1}_{entry_key}% -->', str(entry_value)) html = html.replace(f'<!-- %{item}_{index+1}_{entry_key}% -->', html_line_breaks(str(entry_value)))
with open(f'{filename}.html','w') as file: with open(f'{filename}.html','w') as file: