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}% -->` | 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}` |
|
||||||
|
| `<!-- %template_sheetsize% -->` | Value of `metadata.template.sheetsize` |
|
||||||
|
|
||||||
Note that `{item}`, `{category}` and `{key}` in the description above can be
|
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
|
any valid YAML key, and `{i}` is an integer representing the 1-based index of
|
||||||
|
|||||||
45
src/wireviz/templates/din-6771.html
generated
45
src/wireviz/templates/din-6771.html
generated
@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<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" />
|
||||||
@ -11,8 +12,12 @@
|
|||||||
background-color: < !-- %bgcolor% -->;
|
background-color: < !-- %bgcolor% -->;
|
||||||
}
|
}
|
||||||
|
|
||||||
table, td, th, #frame {
|
table,
|
||||||
border: 0.35mm solid black; /* line weight based on DIN 15 */
|
td,
|
||||||
|
th,
|
||||||
|
#frame {
|
||||||
|
border: 0.35mm solid black;
|
||||||
|
/* line weight based on DIN 15 */
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
@ -22,7 +27,8 @@
|
|||||||
border-spacing: 0mm;
|
border-spacing: 0mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
td, th {
|
td,
|
||||||
|
th {
|
||||||
border-top: 0;
|
border-top: 0;
|
||||||
border-left: 0;
|
border-left: 0;
|
||||||
|
|
||||||
@ -38,17 +44,21 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.A4, .sheetsize_default { /* portrait */
|
.A4,
|
||||||
|
.sheetsize_default {
|
||||||
|
/* portrait */
|
||||||
width: 180mm;
|
width: 180mm;
|
||||||
height: 277mm;
|
height: 277mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.A3 { /* landscape */
|
.A3 {
|
||||||
|
/* landscape */
|
||||||
width: 390mm;
|
width: 390mm;
|
||||||
height: 277mm;
|
height: 277mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.A2 { /* landscape */
|
.A2 {
|
||||||
|
/* landscape */
|
||||||
width: 564mm;
|
width: 564mm;
|
||||||
height: 400mm;
|
height: 400mm;
|
||||||
}
|
}
|
||||||
@ -65,7 +75,8 @@
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
#diagram svg, #diagram img {
|
#diagram svg,
|
||||||
|
#diagram img {
|
||||||
max-width: 95%;
|
max-width: 95%;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -84,17 +95,21 @@
|
|||||||
height: 38.25mm;
|
height: 38.25mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
#titleblock tr, #bom tr {
|
#titleblock tr,
|
||||||
|
#bom tr {
|
||||||
height: 4.25mm;
|
height: 4.25mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.A4 #bom { /* BOM on top of title block */
|
.A4 #bom {
|
||||||
|
/* BOM on top of title block */
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 38.25mm;
|
bottom: 38.25mm;
|
||||||
right: 0;
|
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;
|
position: absolute;
|
||||||
bottom: 0mm;
|
bottom: 0mm;
|
||||||
left: 0mm;
|
left: 0mm;
|
||||||
@ -104,7 +119,8 @@
|
|||||||
width: 180mm;
|
width: 180mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
#bom th, td {
|
#bom th,
|
||||||
|
td {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,10 +176,8 @@
|
|||||||
width: 12.75mm;
|
width: 12.75mm;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<style type="text/css" media="print">
|
<style type="text/css" media="print">
|
||||||
|
|
||||||
@page {
|
@page {
|
||||||
size: auto;
|
size: auto;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -174,12 +188,12 @@
|
|||||||
margin: 10mm;
|
margin: 10mm;
|
||||||
margin-left: 20mm;
|
margin-left: 20mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="page">
|
<div id="page">
|
||||||
<div id="frame" class="sheetsize_default">
|
<div id="frame" class="<!-- %template_sheetsize% -->">
|
||||||
|
|
||||||
<div id="diagram">
|
<div id="diagram">
|
||||||
|
|
||||||
@ -283,4 +297,5 @@
|
|||||||
</div> <!-- /frame -->
|
</div> <!-- /frame -->
|
||||||
</div> <!-- /page -->
|
</div> <!-- /page -->
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@ -145,6 +145,9 @@ def generate_html_output(
|
|||||||
"<!-- %bom_reversed% -->": bom_html_reversed,
|
"<!-- %bom_reversed% -->": bom_html_reversed,
|
||||||
"<!-- %sheet_current% -->": "1", # TODO: handle multi-page documents
|
"<!-- %sheet_current% -->": "1", # TODO: handle multi-page documents
|
||||||
"<!-- %sheet_total% -->": "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:
|
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}% -->"] = (
|
replacements[f"<!-- %{item}_{index+1}_{entry_key}% -->"] = (
|
||||||
html_line_breaks(str(entry_value))
|
html_line_breaks(str(entry_value))
|
||||||
)
|
)
|
||||||
|
elif isinstance(entry, (str, int, float)):
|
||||||
replacements['"sheetsize_default"'] = '"{}"'.format(
|
pass # TODO?: replacements[f"<!-- %{item}_{category}% -->"] = html_line_breaks(str(entry))
|
||||||
metadata.get("template", {}).get("sheetsize", "")
|
|
||||||
)
|
|
||||||
# include quotes so no replacement happens within <style> definition
|
|
||||||
|
|
||||||
# perform replacements
|
# perform replacements
|
||||||
# regex replacement adapted from:
|
# regex replacement adapted from:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user