Skip to content
mdxcn is now part of Shadcn Labs. details

comark

graph-comark

Write figures as ::graph-* blocks in plain Markdown. Comark parses the file and these graphs draw the frames, so there's no MDX compile step anywhere.

For a side-by-side of source and output, see /comark. Every graph rendered through Comark is in the comark demo.

install

Install the graphs first. all.json includes the Comark adapter, so if you used it you're done. If the graphs are already in your repo, add graph-comark on its own.

command

wire

Parse on the server and pass the parsed document to the client, not the raw string. That keeps the Comark parser out of your client bundle. The graphs themselves are client components because they animate.

server

subset

author

Props go in YAML at the top of a ::graph-* block, with the same names as the React props. To put figures side by side, nest them in ::row{cols=2}. Every component page has a Comark tab with a block you can copy.

markdown

coerce

Inline Markdown attributes are always strings, so {value=0.86} arrives as "0.86". Arrays and objects in the YAML block keep their types. coerceProps converts the known numeric props back to numbers, renames class to className, and drops the leading colon from Vue-style keys. The list of numeric props for each graph lives in adapters.ts.

stream

Graphs work with streamed Markdown, like an LLM response arriving a token at a time. Comark closes an unfinished ::graph-table block for you, so it doesn't swallow the rest of the page. YAML only parses once a value is complete, so a timeline grows one event at a time. If the stream cuts off mid-key the parse can throw, so keep the last tree that parsed. A graph missing a required prop draws an empty frame instead of crashing, and graphs remount when their data changes so new rows still animate in.

hosts

GitHub, Linear and READMEs don't run Comark, so use the plain-text figure from the .md tab there. For a working setup, the demo repo renders every graph from a single file.