Adding a custom diagram engine
Info
command only
The command path (an external program) works today. The http path (a remote rendering service) is not built yet; writing it earns a DOC-104 note.
How to write it
Describe an engine as an external command in frontmatter:
The contract is minimal:
After that a ```foo fence in a source file is piped into mytool --svg.
Why declarative rather than a plugin API
There is no JavaScript-level plugin interface. Any program that reads stdin and writes SVG to stdout can be attached, whatever language it is written in.
Three reasons:
- No npm package to publish in order to attach your own tool
- No coupling to Pamphlet's internals, which promise nothing during 0.x
- The process boundary isolates it — a third-party engine crashing cannot take the compiler with it
The cost is one process start per diagram. For compile-time work that happens once, that is acceptable.
What you can do today
There is no substitute path. For diagrams other than Mermaid there are two options:
- Draw the SVG yourself and paste it in as inline
<svg>. Note that it bypasses sanitising and recolouring — it will not follow the dark colour scheme. - Export it as an image and reference it. Via
![](), which base64-embeds it into the output.
Source: ADR-0008