Connect toolchains
Add Schemd to a Markdown pipeline
Handle only schemd fences and leave every other token to the host parser.
- sheet
- 9 / 11
- rev
- v0.2
- sections
- 1
- compiled
- 1
01 / AdapterKeep the compiler boundary small
Schemd is parser-free, and a good adapter keeps it that way. It has exactly two responsibilities — recognize the fence, compile it — and everything past those two lines is someone else's problem, which is how it should be.
import { compileSchematic, parseSchematicFence } from '@schemd/core';
export function renderSchemdFence(body: string, info: string) {
const fence = parseSchematicFence(info);
return fence ? compileSchematic(body, fence).svg : undefined;
}Recognize only the schemd language and hand every other fence straight back to the host parser. Emit the compiled SVG as trusted HTML on the server — and, as everywhere in this documentation, keep arbitrary HTML off that path.
port:IN "Input" at (60, 150) #blue
diode:D1 "Protection" at (360, 150) #cyan [type=zener]
port:OUT "Output" at (660, 150) #emerald
IN.out -> D1.anode #blue [line]
D1.cathode -> OUT.in #emerald [line marker-end=arrow]