Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename placehoder "sheetsize_default" to <!-- %template_sheetsize% --> #380

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/wireviz/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/wireviz/templates/din-6771.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/wireviz/wv_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ def svgdata() -> str:
"<!-- %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:
Expand All @@ -112,11 +115,8 @@ def replacement_if_used(key: str, func: Callable[[], str]) -> None:
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:
Expand Down
Loading