Skip to content

Commit c3bc47f

Browse files
committed
feat: use templating to build rules
1 parent 9f69a0c commit c3bc47f

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

website/build.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import ast
44
from pathlib import Path
55
from shutil import copy2
6+
from string import Template
67

78

89
def _extract_frontmatter(path: Path) -> dict[str, str] | None:
@@ -61,9 +62,14 @@ def main() -> None:
6162

6263
toc = _build_toc(_collect_metadata(root))
6364

64-
_ = dist.mkdir(parents=True, exist_ok=True)
65-
_ = copy2("index.html", dist / "index.html")
66-
_ = (dist / "toc.html").write_text(toc, encoding="utf-8")
65+
dist.mkdir(parents=True, exist_ok=True)
66+
for name in ("index.html", "styles.css", "reset.css"):
67+
_ = copy2(name, dist / name)
68+
69+
template = Path("rules.html").read_text(encoding="utf-8")
70+
rules = Template(template).safe_substitute(rules=toc)
71+
72+
_ = (dist / "rules.html").write_text(rules, encoding="utf-8")
6773

6874

6975
if __name__ == "__main__":

website/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ <h1>Proselint</h1>
1111
<p>
1212
<em>Proselint</em> is a linter for English prose.
1313
It highlights <em>clichés</em>, <em>jargon</em>, <em>illogical phrasing</em>, and other stylistic issues,
14-
much like a spellchecker for style.
14+
much like a spellchecker for style. <br /> <br />
15+
16+
You can navigate the available rules <a href="rules.html">here</a>.
1517
</p>
1618

1719
<h2>Install</h2>

website/rules.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>Proselint</title>
7+
<link rel="stylesheet" href="styles.css">
8+
</head>
9+
<body>
10+
<main>
11+
<h1>Proselint</h1>
12+
<p>
13+
A list of the rules that <em>proselint</em> checks against, or <a href="/">go back.</a>.
14+
</p>
15+
16+
$rules
17+
</main>
18+
19+
<footer>
20+
<p class="sm">
21+
Crafted by <a href="https://github.com/amperser" rel="noopener noreferrer" target="_blank">Amperser Labs</a>
22+
</p>
23+
</footer>
24+
</body>
25+
</html>

0 commit comments

Comments
 (0)