Connect toolchains
Compile only canonical schemd fences
Leave prose parsing to the host and compile bounded schemd blocks with exact diagnostics.
- sheet
- 13 / 16
- rev
- v0.8
- sections
- 1
- compiled
- 1
01 / MarkdownParse the information string before the body
Hand the information string to parseSchematicFence before touching the body. If it returns undefined, the block is not ours — give it straight back to the host parser. If it succeeds, compile the body and surface SchematicSyntaxError.line, because swallowing a broken example only means shipping it.
const fence = parseSchematicFence(token.info);
if (!fence) return next(token);
return compileSchematic(token.text, { ...fence, mode: 'default' }).svg;source:VB "1.8 V" at (80, 130) #blue [type=voltage-dc]
resistor:RB "4.7 k\Omega" at (320, 130) #amber
junction:TAP "V_{tap}" at (560, 130) #cyan
ground:GB "0 V" at (560, 250) #slate
VB.positive -> RB.in #blue [line]
RB.out -> TAP.node #amber [line]
TAP.node -> GB.in #slate [ortho]This site compiles every versioned fence in its own test suite, which is what stops a documentation example from being decoration. Each line keeps its own corpus, and newer syntax is never backfilled into an older one.