Skip to content
Merged
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
20 changes: 13 additions & 7 deletions site/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
jevgate.schema.json, and cli.md from each command's --help, so the pages
always describe the binary they were built with.
"""
import html
import json
import subprocess
import sys
Expand Down Expand Up @@ -52,16 +53,16 @@ def rules_page(binary):
anchor = rule["id"].replace("/", "-")
lines += [
"",
f'<a id="{anchor}"></a>',
f'<a id="{html.escape(anchor)}"></a>',
f"### `{rule['id']}`",
"",
f"**Question:** {rule['inspection']}",
f"**Question:** {text(rule['inspection'])}",
"",
f"- **Key:** `{rule['key']}` · **Version:** {rule['version']}"
+ (" · **Needs tests:** yes" if rule["requires_tests"] else ""),
f"- **Looks at:** {rule['scope']}",
f"- **Evidence unit:** {rule['unit']}",
f"- **Acceptable:** {rule['acceptable_example']}",
f"- **Looks at:** {text(rule['scope'])}",
f"- **Evidence unit:** {text(rule['unit'])}",
f"- **Acceptable:** {text(rule['acceptable_example'])}",
]
policy = rules[0]["decision_policy"]
lines += [
Expand Down Expand Up @@ -137,8 +138,13 @@ def cli_page(binary):
return "\n".join(lines) + "\n"


def cell(text):
return text.replace("|", "\\|").replace("\n", " ")
def text(value):
"""Catalog and schema text as page text: markup characters are escaped."""
return html.escape(value, quote=False)


def cell(value):
return text(value).replace("|", "\\|").replace("\n", " ")


def main():
Expand Down
Loading