# Modules

`@memomori/charon` holds `renderToHtml`, `createRenderer`, `createMarkdown`,
`defaultFences`, `preprocessSource`, `renderStaticPage`, `extractToc`, `slugify`
and `CharonError`. Import everything else by its own path, such as
`@memomori/charon/assets`.

## Rendering

| Path          | Holds                                                |
| ------------- | ---------------------------------------------------- |
| `parser`      | `renderToHtml`, `preprocessSource`, `createMarkdown` |
| `render-code` | code fences: highlighting, tables, placeholders      |
| `syntax`      | class names, attributes and patterns of the output   |
| `frontmatter` | find, read and strip YAML frontmatter                |
| `toc`         | heading outline and slugs                            |
| `tags`        | tag rules, the tag plugin and `noteTags`             |
| `wiki-target` | parse `path#heading^block\|label` targets            |
| `callouts`    | the callout plugin                                   |
| `source-scan` | fence and code-span masks                            |
| `delimited`   | the CSV and TSV parser                               |
| `geojson`     | the GeoJSON parser                                   |
| `errors`      | `CharonError`                                        |

## Static pages

| Path            | Holds                                              |
| --------------- | -------------------------------------------------- |
| `static-page`   | `renderStaticPage`, which chains the modules below |
| `heading-links` | anchor links on headings, and the list of them     |
| `examples`      | `example` fences shown as source beside output     |
| `assets`        | fill embeds and images from a folder of files      |
| `diagrams`      | draw `.mermaid` blocks as inline SVG with pele     |
| `links`         | resolve `.md` links and wikilinks to routes        |

## Browser

| Path            | Holds                                               |
| --------------- | --------------------------------------------------- |
| `geojson-map`   | draw a MapLibre map of GeoJSON; needs Vite          |
| `embedded-maps` | turn each `.geojson-map` block in a page into a map |
| `map-style`     | the base style for maps                             |

`geojson-map` imports MapLibre's worker with `?url` and its CSS, so it runs
only through Vite.

## Docs sites

| Path           | Holds                                                              |
| -------------- | ------------------------------------------------------------------ |
| `docs/site`    | find pages, read frontmatter, order sections, routes (Node)        |
| `docs/page`    | the nav, previous and next, contents and template fill             |
| `docs/outputs` | Markdown copies, search sections, `llms.txt`, sitemap, link checks |
| `docs/build`   | `createDocs`: every page and file by route, plus `check` (Node)    |
| `docs/write`   | `writeDocs`: write a built site to a folder (Node)                 |
| `docs/vite`    | the [Vite plugin](sites/vite.md)                                   |
| `docs/og`      | [social cards](sites/social-cards.md) with Satori                  |
| `docs/client`  | `startDocs`, the browser script                                    |
| `docs/labels`  | `DEFAULT_LABELS` and the `Labels` type                             |

Each piece has its own path, so you can build a different kind of site from
them. `createDocs` takes the Vite plugin's options, with `dir` as a path and
`assets` as a folder and its URL:

```ts
import { createDocs } from '@memomori/charon/docs/build'
import { writeDocs } from '@memomori/charon/docs/write'

const assets = { dir: 'docs/assets', url: '/assets' }
const docs = createDocs({ dir: 'docs', name: 'Acme Docs', assets })
await writeDocs(docs, { out: 'site', assets })
```

`writeDocs` checks the site, throws a `CharonError` listing anything broken,
then writes every page and file. It leaves out the default theme's CSS and
script, which the CLI adds.

## Stylesheets

| Path                 | Holds                                          |
| -------------------- | ---------------------------------------------- |
| `styles.css`         | `reset.css`, `typography.css` and `charon.css` |
| `reset.css`          | a reset scoped to `.charon`                    |
| `typography.css`     | spacing, sizes and base colors                 |
| `charon.css`         | tokens, code, callouts, tags, links and KaTeX  |
| `heading-links.css`  | heading anchors                                |
| `examples.css`       | source beside output                           |
| `assets.css`         | embedded notes and images                      |
| `docs.css`           | the docs chrome                                |
| `docs-layout.css`    | the default theme's layout                     |
| `docs-site.css`      | the whole default theme                        |
| `fonts.css`          | JetBrains Mono, from the shipped `fonts/`      |
| `docs-template.html` | the default template                           |
