From 76420c47cbb04c9a0ca0cf431723ad42d8c7b247 Mon Sep 17 00:00:00 2001 From: Parfii-bot Date: Tue, 21 Apr 2026 19:53:05 +0800 Subject: [PATCH] fix(primitives): make pandoc a per-format dep, not a core prereq Smoke-test surfaced that check_deps hard-failed on missing pandoc even for CSV / JSON / code-fence / image conversions that never call pandoc. Pandoc is now checked lazily by need_pandoc(), invoked only from convert_pandoc and convert_doc (the two paths that actually need it). Matches install.sh soft-warn behavior: pandoc is opt-in for docx/pptx/ html, not a universal requirement. Verified: tomd.sh /tmp/test.csv now returns markdown table with only python3 + jq installed. Co-Authored-By: Claude Opus 4.7 (1M context) --- _primitives/tomd.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/_primitives/tomd.sh b/_primitives/tomd.sh index 7182f7d..c66dbc2 100755 --- a/_primitives/tomd.sh +++ b/_primitives/tomd.sh @@ -8,16 +8,20 @@ set -euo pipefail check_deps() { local missing=() - command -v pandoc >/dev/null 2>&1 || missing+=("pandoc (brew install pandoc)") command -v python3 >/dev/null 2>&1 || missing+=("python3 (system)") command -v jq >/dev/null 2>&1 || missing+=("jq (brew install jq)") if [ "${#missing[@]}" -gt 0 ]; then - echo "[tomd] missing prerequisites:" >&2 + echo "[tomd] missing core prerequisites:" >&2 for m in "${missing[@]}"; do echo "[tomd] - $m" >&2; done - echo "[tomd] hint: brew install pandoc jq && pip3 install pymupdf4llm openpyxl" >&2 + echo "[tomd] hint: brew install jq && pip3 install pymupdf4llm openpyxl" >&2 exit 1 fi } +need_pandoc() { + command -v pandoc >/dev/null 2>&1 && return 0 + echo "[tomd] pandoc required for this format. Install: brew install pandoc" >&2 + exit 1 +} detect_format() { local f="$1" @@ -53,6 +57,7 @@ PYEOF } convert_pandoc() { + need_pandoc local from="${2:-}" if [ -n "$from" ]; then pandoc -f "$from" -t markdown --wrap=none "$1" else pandoc -t markdown --wrap=none "$1"; fi @@ -63,6 +68,7 @@ convert_doc() { echo "[tomd] .doc: textutil not available (macOS only). Convert to .docx first." >&2 exit 1 fi + need_pandoc local tmp; tmp=$(mktemp /tmp/tomd-XXXX.html) textutil -convert html -output "$tmp" "$1" pandoc -f html -t markdown --wrap=none "$tmp"; rm -f "$tmp"