Render Vithanco Graph Language (VGL) diagrams inside VS Code's built-in Markdown preview.
Any fenced block tagged vgl is replaced with the rendered SVG when you open the preview. It fits the preview's width; hover it for − and + (or pinch on a trackpad, or ctrl+scroll) to zoom, and click the percentage to fit it again.
```vgl
vgraph decision: IBIS "Should we ship?" {
node q1: Question "Should we ship?";
node a1: Answer "Yes, soon";
node p1: Pro "Users have asked for it";
node c1: Con "Docs are still thin";
edge q1 -> a1;
edge a1 -> p1;
edge a1 -> c1;
}
```Two extension points do the heavy lifting:
markdown.markdownItPlugins— the extension host renders eachvglfence to SVG with the VGraph WASM engine and embeds it in the preview's HTML. It runs there because the preview's Content Security Policy forbids compiling WebAssembly.markdown.previewScripts— a small script in the preview binds each diagram's zoom controls and keeps its zoom while the preview re-renders on every edit.
The VGraphWasm.wasm binary is embedded directly into the extension bundle (esbuild binary loader). Graphviz layout runs inside that module, so nothing else is bundled for it. No CDN dependencies, no per-document "allow content" prompts.
From the repo root:
./build.sh # runs WASM build, then the extension buildOr, inside this directory:
npm install
npm run build # esbuild → out/extension.js + out/preview.js
npm run package # → vithanco-x.y.z.vsixcode --install-extension vithanco-*.vsixReload VS Code, open a markdown file containing a ```vgl block, and run Markdown: Open Preview to the Side.
vscode-vithanco/
├── src/
│ ├── extension.ts # markdown-it plugin (host side)
│ ├── renderer.ts # WASM init + render (host side)
│ ├── html.ts # what a vgl fence becomes in the preview
│ ├── preview.ts # binds the zoom controls (webview side)
│ └── zoom.ts # zoom, identical in obsidian-vithanco
├── styles.css # contributed via markdown.previewStyles
├── VGraphWasm.wasm # refreshed from ../website/Package/ on build
├── esbuild.config.mjs # bundles host (CJS) and preview (IIFE)
├── release.sh # cuts a release in the standalone repo
└── package.json
The extension is developed inside the VGraph monorepo and released from a separate standalone repo (mirrors the Obsidian plugin setup).
The monorepo copy at vscode-vithanco/ is for development. To publish:
-
Sync this folder into the standalone
vscode-vithancorepo (manualrsyncorgit subtree push— preserve only tracked files; node_modules/, out/, and *.vsix are gitignored). -
From the standalone repo's root, run:
VGRAPH_REPO=/path/to/VGraph ./release.sh 0.1.1
The script refreshes
VGraphWasm.wasmfrom the monorepo, bumps the version inpackage.json, builds, packages, commits, tags, pushes, and creates a GitHub Release with the.vsixattached. -
To also publish to the VS Code Marketplace:
VGRAPH_REPO=/path/to/VGraph PUBLISH=1 ./release.sh 0.1.1
Requires a publisher PAT in
$VSCE_PATor a logged-invscesession (see the VS Code publishing docs).
- Reading view only. Editing a
vglblock in source view shows the raw fence; switch to the preview to see the rendered diagram. - Desktop VS Code only (the Wasm module assumes a desktop runtime, like the sibling Obsidian plugin).
- Graphviz (EPL-2.0) — layout engine, compiled into the WebAssembly module via SwiftGraphviz
- The Swift runtime (Apache-2.0 with Runtime Library Exception) — linked into the WebAssembly module
- DM Sans (SIL OFL 1.1) — the typeface the diagrams use
Engine source (Swift, MCP server, CLI): https://github.com/Vithanco/VGraph
Apache-2.0 — see LICENSE. Third-party components are listed in NOTICE.