Docs menu

Convert one file

View as Markdown
charon notes.md -o notes.html
cat notes.md | charon --page > notes.html

charon reads a file, or stdin when you give none, and writes HTML to stdout or to -o, making its folder if needed. Run with neither in a terminal, it shows its usage instead of waiting. To build a whole site from a folder, use Elysium.

Flags #

Flag Does
-o, --out <file> writes to a file instead of stdout
--page wraps the HTML in a page with Charon's CSS inlined
--title <text> the page title; defaults to the frontmatter title, the first h1, then the file name
--lang <code> the page language; defaults to the frontmatter lang, then en
--headings anchor links on h2 and h3
--contents, --contents-label <text> an "On this page" list of the h2s and h3s, under the label given
--examples example fences as source beside output
--diagrams, --diagram-font <font> mermaid fences as inline SVG
--assets <dir>, --assets-url <url> embeds and images from a folder, at a URL that defaults to the folder as given

--title and --lang need --page. --contents-label turns on --contents, and --diagram-font turns on --diagrams.

Pages #

--page reads a post's frontmatter:

---
title: A week in Hakone
lang: ja
description: Ferries, ropeways and where to stay.
---

title names the page and, when the post has no h1 of its own, heads it. lang sets the page language, and description becomes its <meta name="description">. A page with math links KaTeX's stylesheet from jsDelivr.

Contents #

--contents puts an "On this page" list right after the first h1, or at the top when there is none, as a docs page does. It lists the h2s, with their h3s under them, and only shows once a page has three h2s, so a short post stays as it is. --contents-label names it in another language:

charon post.md --page --headings --contents --contents-label 目次 -o post.html

With --page the list's styles come inlined; without it, add contents.css to your own page.

Images #

Without --assets, an image path resolves against the Markdown file's folder and stays as written, so the HTML works beside the Markdown. A path starting with / stays as is.

charon post/index.md --page --assets shared --assets-url /shared -o out/post.html

Exit codes #

Code Means
0 done
1 rendering failed; it lists every missing link, embed and image at once
2 a bad flag, or no file and nothing piped in