Skip to content

About

Render Vithanco (VGL) diagrams — IBIS, Concept Maps, C4 and more — in VS Code's Markdown preview.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Vithanco for VS Code

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;
}
```

How it works

Two extension points do the heavy lifting:

  • markdown.markdownItPlugins — the extension host renders each vgl fence 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.

Build

From the repo root:

./build.sh               # runs WASM build, then the extension build

Or, inside this directory:

npm install
npm run build            # esbuild → out/extension.js + out/preview.js
npm run package          # → vithanco-x.y.z.vsix

Install locally

code --install-extension vithanco-*.vsix

Reload VS Code, open a markdown file containing a ```vgl block, and run Markdown: Open Preview to the Side.

Layout

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

Release workflow

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:

  1. Sync this folder into the standalone vscode-vithanco repo (manual rsync or git subtree push — preserve only tracked files; node_modules/, out/, and *.vsix are gitignored).

  2. From the standalone repo's root, run:

    VGRAPH_REPO=/path/to/VGraph ./release.sh 0.1.1

    The script refreshes VGraphWasm.wasm from the monorepo, bumps the version in package.json, builds, packages, commits, tags, pushes, and creates a GitHub Release with the .vsix attached.

  3. 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_PAT or a logged-in vsce session (see the VS Code publishing docs).

Limitations

  • Reading view only. Editing a vgl block 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).

Acknowledgements

  • 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

Source and licence

Engine source (Swift, MCP server, CLI): https://github.com/Vithanco/VGraph

Apache-2.0 — see LICENSE. Third-party components are listed in NOTICE.

About

Render Vithanco (VGL) diagrams — IBIS, Concept Maps, C4 and more — in VS Code's Markdown preview.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages