Compare commits

...

3 Commits

Author SHA1 Message Date
3d639f6ec2 Add configurable output DPI setting (port of upstream PR #379)
Some checks are pending
Create Examples / build (ubuntu-22.04, 3.7) (push) Waiting to run
Create Examples / build (ubuntu-22.04, 3.8) (push) Waiting to run
Create Examples / build (ubuntu-latest, 3.10) (push) Waiting to run
Create Examples / build (ubuntu-latest, 3.11) (push) Waiting to run
Create Examples / build (ubuntu-latest, 3.12) (push) Waiting to run
Create Examples / build (ubuntu-latest, 3.9) (push) Waiting to run
Adds output_dpi field to Options (default 96.0) and passes it to the
GraphViz graph attributes. Higher DPI produces sharper PNG/PDF renders,
useful for print-quality harness documentation.
2026-02-13 03:52:30 -07:00
79be720eab Add <!-- %revision% --> template placeholder (port of upstream PR #492)
Adds a _get_latest_revision() helper that extracts the last entry from
metadata.revisions. Allows templates to show the current revision
indicator without rendering the full revision table.
2026-02-13 03:51:37 -07:00
254be36948 Fix SVG MIME type for embedded images (port of upstream PR #443)
SVG images embedded in connector/cable nodes failed to display because
the MIME type was image/svg instead of image/svg+xml per W3C spec.
2026-02-13 03:50:58 -07:00
4 changed files with 11 additions and 1 deletions

View File

@ -40,6 +40,7 @@ Note that there must be one single space between `--` and `%` at both ends.
| `<!-- %sheet_total% -->` | `1` (multi-page documents not yet supported) |
| `<!-- %diagram% -->` | Embedded SVG diagram as valid HTML |
| `<!-- %diagram_png_b64% -->` | Embedded base64 encoded PNG diagram as URI |
| `<!-- %revision% -->` | The name of the last revision |
| `<!-- %{item}% -->` | String or numeric value of `metadata.{item}` |
| `<!-- %{item}_{i}% -->` | Category number `{i}` within dict value of `metadata.{item}` |
| `<!-- %{item}_{i}_{key}% -->` | Value of `metadata.{item}.{category}.{key}` |

View File

@ -87,6 +87,7 @@ class Options:
color_output_mode: ColorOutputMode = ColorOutputMode.EN_UPPER
mini_bom_mode: bool = True
template_separator: str = "."
output_dpi: Optional[float] = 96.0
_pad: int = 0
# TODO: resolve template and image paths during rendering, not during YAML parsing
_template_paths: List = field(default_factory=list)

View File

@ -632,6 +632,7 @@ def set_dot_basics(dot, options):
bgcolor=options.bgcolor.html,
nodesep="0.33",
fontname=options.fontname,
dpi=f"{options.output_dpi}",
) # TODO: Add graph attribute: charset="utf-8",
dot.attr(
"node",

View File

@ -15,7 +15,7 @@ from wireviz.wv_utils import (
smart_file_resolve,
)
mime_subtype_replacements = {"jpg": "jpeg", "tif": "tiff"}
mime_subtype_replacements = {"jpg": "jpeg", "svg": "svg+xml", "tif": "tiff"}
# TODO: Share cache and code between data_URI_base64() and embed_svg_images()
@ -64,6 +64,12 @@ def get_mime_subtype(filename: Union[str, Path]) -> str:
return mime_subtype
def _get_latest_revision(metadata: Dict) -> str:
if "revisions" not in metadata:
return ""
return list(metadata.get("revisions"))[-1]
def embed_svg_images_file(
filename_in: Union[str, Path], overwrite: bool = True
) -> None:
@ -152,6 +158,7 @@ def generate_html_output(
"<!-- %template_sheetsize% -->": metadata.get("template", {}).get(
"sheetsize", ""
),
"<!-- %revision% -->": _get_latest_revision(metadata),
}
def replacement_if_used(key: str, func: Callable[[], str]) -> None: