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) <noreply@anthropic.com>
This commit is contained in:
parent
a9abc6cace
commit
76420c47cb
1 changed files with 9 additions and 3 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue