feat: add superfig paper-figure toolkit

Standalone LaTeX/TikZ skill for non-tensor paper figures: node/edge
macros, lint-on-warning build, golden examples, and negative fixtures.
This commit is contained in:
dela
2026-08-17 09:40:12 +08:00
commit db5598fbf7
39 changed files with 1732 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Toolchain preflight for superfig.
# Exit codes: 0 full path, 1 degraded (no CJK/export), 2 no LaTeX.
set -uo pipefail
QUIET=0
[[ "${1:-}" == "--quiet" ]] && QUIET=1
say() { [[ $QUIET -eq 1 ]] || echo -e "$*"; }
ok=0; warn=0; fail=0; cjk_warn=0; export_warn=0
check() {
local name="$1"; shift
if "$@" >/dev/null 2>&1; then say " ok $name"; ok=$((ok+1)); return 0
else say " MISS $name"; return 1; fi
}
say "superfig preflight"
say "--- required ---"
check "xelatex" command -v xelatex || fail=$((fail+1))
check "standalone.cls" kpsewhich standalone.cls || fail=$((fail+1))
check "tikz.sty" kpsewhich tikz.sty || fail=$((fail+1))
check "array.sty" kpsewhich array.sty || fail=$((fail+1))
check "etoolbox.sty" kpsewhich etoolbox.sty || fail=$((fail+1))
say "--- chinese figures ---"
check "ctex.sty" kpsewhich ctex.sty || { warn=$((warn+1)); cjk_warn=1; }
check "fandol font" kpsewhich FandolSong-Regular.otf || { warn=$((warn+1)); cjk_warn=1; }
say "--- raster / vector export ---"
check "pdftocairo" command -v pdftocairo || { warn=$((warn+1)); export_warn=1; }
if [[ $fail -gt 0 ]]; then
say ""
say "RESULT: no usable LaTeX path."
say "Fall back to SVG/HTML and state that superfig package guarantees are unavailable."
exit 2
fi
if [[ $warn -gt 0 ]]; then
say ""
say "RESULT: degraded."
[[ $cjk_warn -eq 1 ]] && say " - missing ctex/fandol -> English-label figures only."
[[ $export_warn -eq 1 ]] && say " - missing pdftocairo -> PDF only, no PNG/SVG."
exit 1
fi
say ""
say "RESULT: full path available (TikZ + CJK + vector/raster export)."
exit 0