Files
Marcos Paulo 7f432138df
ci / ci (macos-latest) (push) Has been cancelled
ci / ci (ubuntu-latest) (push) Has been cancelled
ci / ci (windows-latest) (push) Has been cancelled
docs: Obsidian plugin parity research, Bases spec and tasks, empty notescraft-bases crate
Inventory of the 29 core plugins (22 done, 2 partial, 5 missing), 80 community plugins with a verdict each, a ranked roadmap with 8 ready briefs, the Bases spec (D1-D13) and 20 tasks, ASCII wireframes of the Bases screens (PaperCraft was not running). crates/bases is registered at layer L2.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 00:30:28 -03:00

2.6 KiB

TASK export-pandoc: export.pandoc through an installed pandoc binary (Pandoc plugin)

Runs through OpenCode (specs/agents/opencode-runbook.md is attached automatically).

OWNS

  • crates/engine/src/pandoc/mod.rs, crates/engine/src/pandoc/run.rs, crates/engine/src/pandoc/commands.rs (new folder), one mod pandoc; line in crates/engine/src/lib.rs, one register_pandoc(reg) call in crates/engine/src/commands.rs::register_core
  • crates/engine/tests/pandoc.rs, crates/engine/tests/core_commands.rs (CORE_IDS), crates/engine/src/ai/assistant_gate.rs (WRITE list)

FILES TO OPEN

  • pattern: crates/engine/src/builtin/export_commands.rs (export.pdf: out_path, reject_outside_vault, write_without_overwrite)
  • crates/engine/src/vault/external.rs (spawning external programs, if any), crates/engine/src/vault/pdf_preview.rs (how pdftoppm is discovered and degraded)

GOAL / API

export.pandoc {path, format: docx|epub|html|odt|latex|rst, out?, resolve_embeds?: bool}:

  • Finds pandoc on PATH (and /opt/homebrew/bin, /usr/local/bin); not found -> error tool_missing with a message naming pandoc and https://pandoc.org/installing.html; the command is enabled only when it is found.
  • Runs pandoc -f gfm+wikilinks_title_after_pipe -t <format> -o <out> with the note text on stdin (wikilinks [[a|b]] become links to titles; embeds replaced by their text when resolve_embeds, up to depth 3), a 60 s timeout, working dir = the note's folder, stderr captured (4 KiB cap) into the error.
  • out defaults to <note>.<ext> beside the note; reject_outside_vault as export.pdf; never overwrites (suffix 2).
  • Arguments are passed as an argv array (never through a shell); format is matched against the list above, so no injection.
  • No network: add --sandbox to the pandoc call.

TESTS

crates/engine/tests/pandoc.rs: use a fake pandoc shell script placed in a temp dir put FIRST on a PATH override parameter (add Session-free function run_pandoc(bin: &Path, ...) and test that; do not depend on a real pandoc): argv exactly as specified, timeout kills a sleeping fake, stderr surfaced, tool_missing when absent, out outside the vault refused, no overwrite, bad format refused.

VERIFY

export PATH="$HOME/.cargo/bin:$PATH"
cargo test -p notescraft-engine --test pandoc
cargo test -p notescraft-engine --test core_commands
cargo clippy -p notescraft-engine --all-targets -- -D warnings
rustfmt --edition 2024 crates/engine/src/pandoc/*.rs crates/engine/tests/pandoc.rs

DO NOT

Add a dependency (use std::process::Command); bundle pandoc; add UI (an Export submenu entry is a follow-up); run through sh -c.