Guide

Inline SVG directives

Parse-time chart rendering with ::vl, ::vg, ::chart, and mark shortcuts — no runtime component required.

For static output without a runtime component, these directives render the chart as inline SVG at parse time.

::vl — Vega-Lite

The spec JSON must be wrapped in a code fence inside the block body. Comark reserves {...} syntax in block bodies for directive attributes; a code fence is the only safe way to pass JSON without mangling.

::vl{width="500" height="300" output="svg"}
```
{
  "$schema": "https://vega.github.io/schema/vega-lite/v6.json",
  "mark": "bar",
  "data": {
    "values": [
      { "product": "Valves", "sales": 42000 },
      { "product": "Pipes",  "sales": 31500 }
    ]
  },
  "encoding": {
    "x": { "field": "sales",   "type": "quantitative" },
    "y": { "field": "product", "type": "nominal" }
  }
}
```
::

Alias: ::vega-lite.

::vg — Full Vega

::vg
```
{
  "$schema": "https://vega.github.io/schema/vega/v6.json",
  "width": 300,
  "height": 150,
  "data": [{ "name": "table", "values": [{ "x": "A", "y": 4 }] }],
  "marks": [{ "type": "rect", "from": { "data": "table" }, ... }]
}
```
::
::vega was previously an alias for ::vg. It is now a separate component directive that produces a <Vega> node — see Entry points. Use ::vg for full-Vega inline SVG.

::chart — Auto-detect engine

::chart{engine="vega-lite"}
{ ... }
::

Engine is inferred in this order:

  1. engine= attr (vega-lite | vega)
  2. Directive tag (::vl → vega-lite, ::vg → vega)
  3. $schema URL in spec
  4. Presence of mark/layer/hconcat/… → vega-lite; marks/signals/… → vega
  5. Default: vega-lite

Spec sources for inline-SVG

The chart spec is resolved from these sources (in priority order):

  1. Code-fenced block body — the recommended format. Wrapping the spec in a code fence preserves it as raw text.
  2. spec= attr — only reliable for simple, flat specs with at most one level of object nesting. Comark's attr parser may misinterpret nested braces inside quoted attr values.

See Mark shortcuts for sugar directives like ::chart-bar.

Copyright © 2026