Added <!-- %revision% --> place-holder

This commit is contained in:
ishaid 2026-01-04 22:38:58 +02:00
parent 01c3771a9c
commit 22c525015c
2 changed files with 9 additions and 0 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) | | `<!-- %sheet_total% -->` | `1` (multi-page documents not yet supported) |
| `<!-- %diagram% -->` | Embedded SVG diagram as valid HTML | | `<!-- %diagram% -->` | Embedded SVG diagram as valid HTML |
| `<!-- %diagram_png_b64% -->` | Embedded base64 encoded PNG diagram as URI | | `<!-- %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}% -->` | String or numeric value of `metadata.{item}` |
| `<!-- %{item}_{i}% -->` | Category number `{i}` within dict value of `metadata.{item}` | | `<!-- %{item}_{i}% -->` | Category number `{i}` within dict value of `metadata.{item}` |
| `<!-- %{item}_{i}_{key}% -->` | Value of `metadata.{item}.{category}.{key}` | | `<!-- %{item}_{i}_{key}% -->` | Value of `metadata.{item}.{category}.{key}` |

View File

@ -64,6 +64,13 @@ def get_mime_subtype(filename: Union[str, Path]) -> str:
return mime_subtype return mime_subtype
def _get_latest_revision(metadata: Dict) -> str:
if not "revisions" in metadata:
return ""
revision = list(metadata.get("revisions"))[-1]
return revision
def embed_svg_images_file( def embed_svg_images_file(
filename_in: Union[str, Path], overwrite: bool = True filename_in: Union[str, Path], overwrite: bool = True
) -> None: ) -> None:
@ -148,6 +155,7 @@ def generate_html_output(
"<!-- %template_sheetsize% -->": metadata.get("template", {}).get( "<!-- %template_sheetsize% -->": metadata.get("template", {}).get(
"sheetsize", "" "sheetsize", ""
), ),
"<!-- %revision% -->": _get_latest_revision(metadata),
} }
def replacement_if_used(key: str, func: Callable[[], str]) -> None: def replacement_if_used(key: str, func: Callable[[], str]) -> None: