name: convert-to-pdf description: Converts markdown documents to PDF using pandoc with typst as the PDF engine. Use when the user wants to turn a markdown doc into a PDF. argument-hint: "[markdown file(s) and any styling/output direction]" allowed-tools: Bash(pandoc:), Bash(typst:), Bash(ls:*), Read, Glob, Write, Edit
Convert to PDF
Converts one or more markdown documents to PDF, following any direction the user gives about styling or output location.
Workflow
Identify the source markdown file(s) from the argument or conversation. Use Glob if a path is ambiguous or partial.
Convert with pandoc using typst as the PDF engine:
pandoc <input.md> -f markdown-citations -o <output.pdf> --pdf-engine=typstAlways disable the
citationsextension (-f markdown-citations). Otherwise pandoc treats@wordtokens, such as scoped npm package names like@hono/node-server, as citation references and typst fails with "the document does not contain a bibliography".By default, write the PDF next to the input file with the same basename. Honor any output path the user specifies.
Apply user direction through pandoc options where possible:
- Page setup:
-V margin=...,-V papersize=...,-V fontsize=... - Metadata:
-M title="...",-M author="...",-M date="..." - Table of contents:
--toc
- Page setup:
For styling beyond what pandoc variables cover (custom fonts, headers/footers, colors, layout), generate an intermediate typst file, edit it, then compile:
pandoc <input.md> -f markdown-citations -o <doc.typ> --standalone typst compile <doc.typ> <output.pdf>Verify the PDF exists with
ls -laand report the output path to the user.
Guidelines
- Keep defaults simple when the user gives no direction. Do not invent styling they did not ask for.
- Surface pandoc or typst errors plainly rather than silently retrying with different options.
- For multiple input files, ask whether the user wants one combined PDF or one PDF per file, unless the context makes it obvious.