# Code blocks

## Highlighted code

````md
```ts
const fare = (heads: number) => heads * 1
```
````

Name the language after the backticks to color the code. Every block gets a
copy button; a docs site wires it up, and in your own page
[`startDocs`](sites/search.md#client) or a click handler of yours does.

## Tables from CSV

````md
```csv
river,meaning,length km
Styx,hate,
Acheron,woe,58
Lethe,forgetting,
```
````

A `csv` or `tsv` fence draws a table. The first row becomes the header.
`parseDelimited` from `@memomori/charon/delimited` is the parser behind it.

## Diagrams

````md
```mermaid
graph LR
  Shore --> Ferry --> Underworld
  Ferry -.-> Shore
```
````

A `mermaid` fence renders as `<div class="mermaid" data-content="…">`, its
source in base64 UTF-8. To draw it as inline SVG at build time, use the
`diagrams` module, which needs `pele`. A docs site draws every diagram for you.

## Maps

````md
```geojson
{
  "type": "Point",
  "coordinates": [
    21.6,
    39.2
  ]
}
```
````

A `geojson` fence renders as `<div class="geojson-map" data-content="…">`.
To draw the maps in the browser, take them from the page:

```ts
import { embeddedMaps } from '@memomori/charon/embedded-maps'
import { tileStyle } from '@memomori/charon/map-style'

const maps = embeddedMaps(tileStyle('light'))
maps.take(article)
```

Each map draws once it nears the screen. `restyle` swaps the style, for a
dark theme, and `remove` tears them all down. It needs `maplibre-gl` and Vite.
`tileStyle` points at OpenFreeMap. A docs site leaves maps alone.

## Examples

````md
```example
**Bold** and _italic_.
```
````

An `example` fence shows its source beside its output, as on every page here.
Turn it on with `examples` in [`renderStaticPage`](static-pages.md), `--examples`
on the [CLI](cli.md), or use a docs site, which always has it.

## Your own fences

Give any language your own renderer, or turn off a built-in one. See
[Custom fences](fences.md).
