summaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-23 11:50:44 -0600
committerGitHub <noreply@github.com>2026-11-23 11:50:44 -0600
commiteee36d11e17a79b3a9727d2936f30511a4af13c8 (patch)
tree22449ab76bbe49bed35b5e6c54019d2802301d6a /scripts
parenta847b938b372995762c8ab581c0be521fd2e8bcb (diff)
parentb6574b2f3cb86d33d7e55985c7914dfce6dbf296 (diff)
downloadzash-eee36d11e17a79b3a9727d2936f30511a4af13c8.tar.gz
Merge pull request #4 from skurtz97/docs/logo-and-clean
docs: one centred logo, and clean removes what the makefile builds
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/spec-pdf.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/spec-pdf.sh b/scripts/spec-pdf.sh
new file mode 100755
index 0000000..6870654
--- /dev/null
+++ b/scripts/spec-pdf.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+# shellcheck shell=sh
+#
+# spec-pdf.sh - typeset formal/zash-spec.typ into formal/zash-spec.pdf
+#
+# usage: spec-pdf.sh [-v] [out.pdf]
+#
+# Run from anywhere inside the repository. The root passed to typst is the
+# repository root, because the spec reads ../packaging/zash-logo.svg and
+# typst refuses files outside its root.
+#
+# Uses the typst CLI if it is on PATH, otherwise the Python package
+# (pip install typst), which is how the PDF was first built.
+
+set -eu
+
+verbose=0
+if [ "${1-}" = -v ]; then
+ verbose=1
+ shift
+fi
+
+root=$(cd "$(dirname "$0")/.." && pwd)
+src=$root/formal/zash-spec.typ
+out=${1:-$root/formal/zash-spec.pdf}
+
+[ -f "$src" ] || { echo "spec-pdf.sh: $src: not found" >&2; exit 1; }
+
+if command -v typst >/dev/null 2>&1; then
+ [ "$verbose" = 1 ] && echo "typst CLI: $(typst --version)" >&2
+ typst compile --root "$root" "$src" "$out"
+elif python3 -c 'import typst' 2>/dev/null; then
+ [ "$verbose" = 1 ] && echo "typst Python package" >&2
+ python3 - "$src" "$out" "$root" <<'EOF'
+import sys
+import typst
+src, out, root = sys.argv[1:]
+typst.compile(src, output=out, root=root)
+EOF
+else
+ echo "spec-pdf.sh: need typst (CLI) or 'pip install typst'" >&2
+ exit 1
+fi
+
+[ "$verbose" = 1 ] && echo "wrote $out" >&2
+exit 0