v0.2 · Connect toolchains
Add Schemd to a Markdown pipeline
Handle only schemd fences and leave every other token to the host parser.
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, and 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; hand every other fence straight back to the host parser. Emit the compiled SVG as trusted HTML on the server — and, as everywhere else in this documentation, keep arbitrary HTML well 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]