SchemaTex Diagrams
Render SchemaTex diagrams inline in the VS Code Markdown preview.
How to use
Add a fenced code block with the schematex language tag to render a diagram inline in the Markdown preview:
```schematex
genogram
Alice -- Bob
```
Optionally prefix the diagram body with a ----delimited config header to control rendering:
```schematex
---
theme: dark
fontFamily: Georgia
---
genogram
Alice -- Bob
```
See Configuration reference below for the full list of supported keys.
The DSL inside a schematex fence gets syntax highlighting while editing (comments, strings, numbers, diagram-type keywords, body-level statement keywords like table, participant, or category, relationship operators, and attribute/config keys).
See the examples/ directory for a short, renderable sample of every supported diagram type — open any file's Markdown preview to see it rendered.
Zoom with Ctrl/Cmd+scroll (zooms toward the cursor), or use the −/⟲/+ buttons that appear on hover in the top-left corner. Click and drag to pan once zoomed in, or hold Ctrl/Cmd and drag at any zoom level (the cursor turns into a hand while the key is held, and text stops being selectable so a pan drag doesn't accidentally select text); the reset (⟲) button returns to the original 100% size and position.
Diagnostics
Invalid config header values (an unrecognized key, an out-of-range theme,
a non-numeric width/height/padding, a non-boolean scene) and DSL
body errors are shown as squiggly underlines and Problems-panel entries,
updated live as you edit — no need to open the preview.
Explanation
What is SchemaTex
SchemaTex is a text-based DSL for describing diagrams — genograms, flowcharts, and similar node-and-edge structures — as plain text, then rendering them as SVG. This extension wires SchemaTex into VS Code's built-in Markdown preview via a markdown-it plugin, so a ```schematex fenced code block renders as a diagram instead of a plain code block whenever you open the Markdown preview.
Licensing
SchemaTex is licensed AGPL-3.0. This extension bundles the schematex package directly (it is not an optional peer dependency), so the AGPL-3.0's copyleft terms extend to the extension as a whole. As a result, this extension is licensed AGPL-3.0-only rather than a more permissive license.
Configuration reference
Config keys go in the optional ----delimited header at the top of a schematex fenced code block, before the diagram body.
| Key |
Type |
Description |
theme |
string |
Diagram color theme (default, dark, or monochrome). Defaults to a theme matching your current VS Code color theme; set this to override it per diagram. |
fontFamily |
string |
Font family used for diagram text. |
width |
number |
Rendered diagram width, in pixels. |
height |
number |
Rendered diagram height, in pixels. |
padding |
number |
Padding around the diagram content, in pixels. |
scene |
boolean |
Opt in to derived geometry/source metadata and data-sx-* SVG hooks on the rendered diagram. |
backgroundColor |
string |
Background color behind the diagram (e.g. #f5f5f5, transparent). Applied as the preview container's background. Not a SchemaTex option — handled entirely by this extension. |
License
AGPL-3.0-only. Bundles schematex (AGPL-3.0).