Export a Markdown document with a Mermaid diagram to PDF

Your Markdown document holds a Mermaid block, a table, sometimes a formula. Marko renders it on your Mac and exports it to a paginated PDF, diagram included. The job here is simple: cleanly ship a Markdown document that contains a chart.

What Marko renders

Marko stays a Markdown editor, not a diagram workshop. It renders what your document describes, including diagrams written inside a code block. When you open a file with a Mermaid block, Marko turns it into an image, in its place within the text.

On a check run against an internal corpus, every Mermaid diagram present was rendered, twenty for twenty. A DOT graph goes through the same way, as an image. GFM tables and KaTeX formulas render too, inline and as blocks.

The diagram often comes from your AI

Claude, ChatGPT or Codex will happily answer with a Mermaid block when you ask for a flow chart or a sequence. You get back text like this:

```mermaid
graph TD
  A[Idea] --> B[Brief]
  B --> C[Review]
  C --> D[PDF export]
```

Pasted into a plain text editor, that block stays code. In Marko, you paste it in Source mode, switch to Visual mode, and the chart appears. You fix a label if needed, then export.

Prepare and export the document

  1. In Marko, open your .md file or create a document.
  2. Write or paste a Mermaid code block with your diagram, and add a table if your document has one.
  3. Switch to Visual mode: the diagram shows as an image, the table takes its shape.
  4. In the File menu, choose “Export as PDF…”, name the file and confirm.

The PDF is paginated as A4, with an “n / N” page number in the footer. The Mermaid diagram and the table appear in the exported document.

An example to try

You can download the example brief to see the export path. That brief has a table, but no Mermaid block. To test diagram rendering, open one of your own documents that has one, or paste into the brief the block your AI returned before you export.

One document, several kinds of blocks

A spec often pulls together a flow chart, a table of owners and a formula. Marko renders all three in the same document: the Mermaid diagram as an image, the GFM table, the KaTeX formula inline or as a block. The export carries the whole thing across the same pages, with no need to pull each piece out on its own.

The rendering and the export happen on your Mac. The file is not sent to a service to produce the diagram image or the PDF.

What the PDF keeps

Document elementIn the PDF
Mermaid diagramRendered as an image
DOT graphRendered as an image
GFM tablesRendered; across pages, the header repeats at the top of each page
KaTeX formulasRendered inline and as blocks

The limits to know

Worth knowing before you rely on export for a large document or for accessibility.

If you mostly need to keep the source, Marko writes plain Markdown, Mermaid block included, which your colleagues reopen in the editor of their choice. The full trial runs for fourteen days, with no account and no card.

Frequently asked questions

Is Marko a diagram editor?

No. Marko stays a Markdown editor. It renders a Mermaid diagram written in the document and includes it in the PDF, but it is not a standalone diagram workshop.

Does the example brief contain a Mermaid block?

No. The example brief has a table, but no Mermaid block. To test diagram rendering, paste in the block your AI returned, or open one of your own documents that has one.

Does the diagram go to a service to be rendered?

No. The rendering and the export happen on your Mac. The file is not sent to a service to produce the diagram image or the PDF.

Do a table and a formula also go into the PDF?

Yes. The Mermaid diagram becomes an image; the GFM table and the KaTeX formula are rendered too, and the export carries the whole thing.

Try it on your own file. Open a .md your AI just wrote, fix it and export it. Marko runs on Apple Silicon Macs, macOS 12 or later.

Download Marko for Mac

Full 14-day trial, no account or credit card. See pricing