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"