docs/guides/write a document

Guides

Write a document

Turn Markdown or HTML you wrote into a file people open: a Word document, a PDF, a deck or an e-book.

From Markdown

Write the Markdown, then convert it. The extension of the output names the format.

ToWhat you get
docxHeadings, lists, tables, code blocks and images as native Word elements, in the default styles
pdfTypeset pages, A4 unless page_size says letter
pptxA section title slide for each top-level heading, and a slide for each second-level heading
epubAn e-book with a chapter at each top-level heading
htmlOne standalone page with simple built-in styles, or a reveal.js deck with slides
odtHeadings, lists, tables, code blocks and images as OpenDocument elements

cv targets review.md lists every target, each with what it keeps and drops.

Terminal
$ export CV_API_KEY=cv_sk_…

Set your key once. Every cv command reads it.

review.md
---title: Pier 3 lease reviewauthor: Port office--- # Summary The lease runs for two years from 1 March 2026. ## Rent | Due | Amount ||---|---|| Rent | 1,300 || Deposit | 2,600 |
Terminal
$ cv convert review.md review.docx
stderrreview.docx (11392 bytes) -> review.docx

Title and author

An e-book and an HTML page take their title and author from a YAML block at the top of the Markdown, as in review.md above. Without one, an HTML page is titled after the file name.

From HTML

HTML prints to PDF the way Chrome prints it: modern CSS, web fonts and JavaScript charts render first. Pages are A4 unless the CSS sets a size.

Common libraries such as Tailwind, Chart.js and MathJax load from a local copy of their CDN. Other remote resources do not load, so put styles and pictures in the page.

HTML to docx keeps headings, paragraphs, lists, tables, links and embedded images, and drops CSS layout, colors and scripts.

Terminal
$ cv convert invoice.html invoice.pdf
stderrinvoice.pdf (88214 bytes) -> invoice.pdf

Join several files

Give several inputs and one output file, and they are joined into one. Each input is converted to the format the join takes, then joined in the order given.

In the API, output.shape set to one joins the inputs. Without it, each input is converted on its own, as cv does with a directory as the output.

Markdown files join into one e-book with --to epub, and PDFs join into one PDF. When some inputs cannot become the format the join takes, the job fails with unsupported_elements.

Terminal
$ cv convert intro.md terms.md annex.md lease-pack.pdf
stderrlease-pack.pdf (64190 bytes) -> lease-pack.pdf

Page size and slides

--opt page_size=letter sets Letter pages for Markdown or HTML to PDF. --opt slides=true turns Markdown into a reveal.js deck, one slide for each second-level heading and a title slide for each first-level one.

cv targets talk.md --json lists the options each target takes, with their ranges and defaults. See Options.

Terminal
$ cv convert talk.md talk.html --opt slides=true
stderrtalk.html (9877 bytes) -> talk.html