MarsDawn

marsdawn for agents

A reference for AI agents and scripts that call the marsdawn command-line tool. Every example on this page was run against the tool built from the current source.

To turn a Markdown file into a PDF, run marsdawn export notes.md --json and read one JSON object from stdout. Mermaid diagrams and highlighted code are rendered the same way as in the MarsDawn app. export doesn't need the app; open does.

What it does

What it does not do

export

marsdawn export notes.md --json

Writes notes.pdf next to notes.md. Options:

marsdawn export notes.md -o out.pdf --theme classic --paper letter --force --json

Success, exit code 0:

{"diagramErrors":[],"ok":true,"output":"/path/to/out.pdf","pages":1,"paper":"letter","theme":"classic"}

open

marsdawn open notes.md --json
marsdawn open notes.md:120 --json
marsdawn open notes.md --line 120 --json

Success, exit code 0:

{"app":"/Applications/MarsDawn.app","ok":true,"opened":[{"line":120,"path":"/path/to/notes.md"}]}

marsdawn 0.2.x printed opened as a list of path strings. Check marsdawn --version if you need to handle both.

Failures

With --json, a failure prints one JSON object on stdout and exits with its code:

{"error":"output_exists","message":"/path/to/notes.pdf already exists. Pass --force to replace it.","ok":false}

JSON Schemas

JSON Schema (draft 2020-12) for every --json result:

Environment variables

Requirements

Install

With Homebrew. The formula compiles marsdawn from source, which takes a few minutes and needs Xcode 26 or later.

brew tap redtear1115/tap && brew install marsdawn
marsdawn --version

Or build it from the source. The first build fetches dependencies and compiles, which also takes a few minutes.

git clone https://github.com/redtear1115/mars-dawn-kit.git
cd mars-dawn-kit
swift build -c release --product marsdawn
.build/release/marsdawn export notes.md --json

marsdawn --version prints the version number, such as 0.3.0, and exits with code 0.