Code blocks
View as MarkdownHighlighted 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. An Elysium docs site makes it work; on your own page,
call its startDocs or add a click handler.
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-app/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. An Elysium 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 workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?url'
import { embeddedMaps } from '@memomori-app/charon/embedded-maps'
import {
pageColorScheme,
tileStyle,
watchColorScheme,
} from '@memomori-app/charon/map-style'
const maps = embeddedMaps(tileStyle(pageColorScheme()), { workerUrl })
maps.take(article)
watchColorScheme((scheme) => maps.restyle(tileStyle(scheme)))
Each map draws once it nears the screen. restyle swaps the style and
remove deletes every map. pageColorScheme reads whether the page shows
light or dark, from the color-scheme on its root or else the system, and
watchColorScheme calls back when that changes, so maps follow a
theme button. The module needs maplibre-gl, the
URL of MapLibre's worker, and a bundler that loads CSS imports.
tileStyle points at OpenFreeMap. An Elysium 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 build an Elysium 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.