Standalone LaTeX/TikZ skill for non-tensor paper figures: node/edge macros, lint-on-warning build, golden examples, and negative fixtures.
48 lines
1.7 KiB
Bash
Executable File
48 lines
1.7 KiB
Bash
Executable File
#!/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
|