Code blocks
Highlighted code #
const fare = (heads: number) => heads * 1
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 or a click handler of yours does.
Tables from CSV #
river,meaning,length km
Styx,hate,
Acheron,woe,58
Lethe,forgetting,
| 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 #
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 #
{
"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:
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 #
**Bold** and _italic_.
An example fence shows its source beside its output, as on every page here.
Turn it on with examples in renderStaticPage, --examples
on the CLI, 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.