For AI agents: the complete documentation index is available at https://lazygophers.github.io/pamphlet/en/llms.txt, the full documentation bundle is available at https://lazygophers.github.io/pamphlet/en/llms-full.txt, and this page is available as Markdown at https://lazygophers.github.io/pamphlet/en/howto/custom-engine.md.

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:

---
engines:
  myengine:
    langs: [foo]
    command: [mytool, --svg]
---

The contract is minimal:

ItemContract
How the diagram source gets instdin
How the SVG comes outstdout
How failure is signalledNon-zero exit code

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:

  1. 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.
  2. Export it as an image and reference it. Via ![](), which base64-embeds it into the output.

Source: ADR-0008