# Convert one file

```sh
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`. To build a whole site from a folder, use
[`charon build`](sites/index.md).

## Flags

Each flag turns on one module:

| 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 |
| `--headings`                           | anchor links on `h2` and `h3`                                                           |
| `--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          |

With `--page`, a page with math links KaTeX's stylesheet from jsDelivr.

## 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.

```sh
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                                                             |
