Introducing Schemd: a small text-to-SVG compiler for circuits and UML
This is what the narrator says, not what the page shows: equations are read as sentences, code blocks are described, and citations are spoken as citations.
-
I like diagrams that live close to the code they explain. An exported image is easy to forget, difficult to review, and usually out of date after a few changes.
-
That is why I built at schemd slash core, a zero-dependency compiler that turns a small text format into accessible SVG.
-
Schemd currently handles common circuit components, classical and quantum gates, configurable ICs, and the UML diagrams I use most often: class, sequence, state, and use-case diagrams. It runs on the server or during a build, so the browser does not need the compiler or a Markdown package.
-
A quick example
-
Install the package: The shell code below is 1 line.
-
Then compile a diagram: The TypeScript code below is 17 lines.
-
The result is deterministic inline SVG with a title, description, intrinsic dimensions, and safe text output:
-
Orthogonal wires avoid component bodies and receive bridge arcs where they cross.
-
UML uses the same syntax: The code below is 4 lines.
-
Why another diagram tool?
-
I wanted a compiler with a narrow job:
-
no runtime dependencies;
-
no DOM or browser layout pass;
-
useful SVG from one function call;
-
source that is readable in a pull request;
-
bounded work and predictable output;
-
enough styling hooks for documentation and simulations.
-
The compiler entry has a hard 20 KiB gzip budget in CI. The current build is around 18 KiB. Code coverage is also enforced at 100% for statements, branches, functions, and lines.
-
Schemd does not include a Markdown parser. A host can detect a schemd fence with Marked, markdown-it, unified, or its own parser, then pass only the fence body to core. This keeps the package small and lets each application keep its existing Markdown pipeline.
-
Try it
-
The playground compiles on the server and shows the result as you type. The simulation lab uses the optional SVG metadata to connect diagrams to live circuit and quantum examples.
-
The documentation covers the grammar, components, math labels, output modes, framework adapters, and Markdown integrations. The source is available on GitHub.
-
A note on scope
-
Version 0.2.0 is a foundation, not a claim that every engineering or UML notation is already present. Some symbols and diagram semantics are still missing, and dense automatic layout remains hard work. I would rather be clear about that and improve it with real examples than hide the limits behind a broad promise.
-
Contributions are welcome, especially for missing symbols, adversarial routing cases, UML notation, accessibility, and browser rendering differences. If a change affects the grammar, please open an issue first so we can keep the language coherent and the compiler within its size budget.
-
I built Schemd for my own technical writing and engineering tools. I hope it also makes your diagrams easier to maintain.