Rename "sheetsize_default" to <!-- %template_sheetsize% --> (#380)
Fixes #377 (makes HTML output template placeholders more consistent) Co-authored-by: kvid <kvid@users.noreply.github.com>
This commit is contained in:
parent
860844574f
commit
f5c00fa31c
@ -43,6 +43,7 @@ Note that there must be one single space between `--` and `%` at both ends.
|
||||
| `<!-- %{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}` |
|
||||
| `<!-- %template_sheetsize% -->` | Value of `metadata.template.sheetsize` |
|
||||
|
||||
Note that `{item}`, `{category}` and `{key}` in the description above can be
|
||||
any valid YAML key, and `{i}` is an integer representing the 1-based index of
|
||||
|
||||
55
src/wireviz/templates/din-6771.html
generated
55
src/wireviz/templates/din-6771.html
generated
@ -1,18 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="<!-- %generator% -->">
|
||||
<title><!-- %title% --></title>
|
||||
<style>
|
||||
body {
|
||||
font-family: <!-- %fontname% -->;
|
||||
background-color: <!-- %bgcolor% -->;
|
||||
font-family: < !-- %fontname% -->;
|
||||
background-color: < !-- %bgcolor% -->;
|
||||
}
|
||||
|
||||
table, td, th, #frame {
|
||||
border: 0.35mm solid black; /* line weight based on DIN 15 */
|
||||
table,
|
||||
td,
|
||||
th,
|
||||
#frame {
|
||||
border: 0.35mm solid black;
|
||||
/* line weight based on DIN 15 */
|
||||
}
|
||||
|
||||
table {
|
||||
@ -22,7 +27,8 @@
|
||||
border-spacing: 0mm;
|
||||
}
|
||||
|
||||
td, th {
|
||||
td,
|
||||
th {
|
||||
border-top: 0;
|
||||
border-left: 0;
|
||||
|
||||
@ -38,17 +44,21 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.A4, .sheetsize_default { /* portrait */
|
||||
.A4,
|
||||
.sheetsize_default {
|
||||
/* portrait */
|
||||
width: 180mm;
|
||||
height: 277mm;
|
||||
}
|
||||
|
||||
.A3 { /* landscape */
|
||||
.A3 {
|
||||
/* landscape */
|
||||
width: 390mm;
|
||||
height: 277mm;
|
||||
}
|
||||
|
||||
.A2 { /* landscape */
|
||||
.A2 {
|
||||
/* landscape */
|
||||
width: 564mm;
|
||||
height: 400mm;
|
||||
}
|
||||
@ -65,7 +75,8 @@
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#diagram svg, #diagram img {
|
||||
#diagram svg,
|
||||
#diagram img {
|
||||
max-width: 95%;
|
||||
max-height: 100%;
|
||||
position: relative;
|
||||
@ -84,27 +95,32 @@
|
||||
height: 38.25mm;
|
||||
}
|
||||
|
||||
#titleblock tr, #bom tr {
|
||||
#titleblock tr,
|
||||
#bom tr {
|
||||
height: 4.25mm;
|
||||
}
|
||||
|
||||
.A4 #bom { /* BOM on top of title block */
|
||||
.A4 #bom {
|
||||
/* BOM on top of title block */
|
||||
position: absolute;
|
||||
bottom: 38.25mm;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.A3 #bom, .A2 #bom { /* BOM to the left of title block */
|
||||
.A3 #bom,
|
||||
.A2 #bom {
|
||||
/* BOM to the left of title block */
|
||||
position: absolute;
|
||||
bottom: 0mm;
|
||||
left: 0mm;
|
||||
}
|
||||
|
||||
#bom table {
|
||||
width:180mm;
|
||||
width: 180mm;
|
||||
}
|
||||
|
||||
#bom th, td {
|
||||
#bom th,
|
||||
td {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
@ -160,10 +176,8 @@
|
||||
width: 12.75mm;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
</style>
|
||||
<style type="text/css" media="print">
|
||||
|
||||
@page {
|
||||
size: auto;
|
||||
margin: 0;
|
||||
@ -174,12 +188,12 @@
|
||||
margin: 10mm;
|
||||
margin-left: 20mm;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="page">
|
||||
<div id="frame" class="sheetsize_default">
|
||||
<div id="frame" class="<!-- %template_sheetsize% -->">
|
||||
|
||||
<div id="diagram">
|
||||
|
||||
@ -283,4 +297,5 @@
|
||||
</div> <!-- /frame -->
|
||||
</div> <!-- /page -->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
||||
@ -145,6 +145,9 @@ def generate_html_output(
|
||||
"<!-- %bom_reversed% -->": bom_html_reversed,
|
||||
"<!-- %sheet_current% -->": "1", # TODO: handle multi-page documents
|
||||
"<!-- %sheet_total% -->": "1", # TODO: handle multi-page documents
|
||||
"<!-- %template_sheetsize% -->": metadata.get("template", {}).get(
|
||||
"sheetsize", ""
|
||||
),
|
||||
}
|
||||
|
||||
def replacement_if_used(key: str, func: Callable[[], str]) -> None:
|
||||
@ -170,11 +173,8 @@ def generate_html_output(
|
||||
replacements[f"<!-- %{item}_{index+1}_{entry_key}% -->"] = (
|
||||
html_line_breaks(str(entry_value))
|
||||
)
|
||||
|
||||
replacements['"sheetsize_default"'] = '"{}"'.format(
|
||||
metadata.get("template", {}).get("sheetsize", "")
|
||||
)
|
||||
# include quotes so no replacement happens within <style> definition
|
||||
elif isinstance(entry, (str, int, float)):
|
||||
pass # TODO?: replacements[f"<!-- %{item}_{category}% -->"] = html_line_breaks(str(entry))
|
||||
|
||||
# perform replacements
|
||||
# regex replacement adapted from:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user