Skip to content

Math and Mermaid extensions

Math and Mermaid are optional packages. They are not dependencies of @markvia/core.

Terminal window
pnpm add @markvia/math @markvia/mermaid

Use only the plugin that your application needs:

import { createMarkdown } from '@markvia/core'
import { createMathPlugin } from '@markvia/math'
import { createMermaidPlugin } from '@markvia/mermaid'
const runtime = createMarkdown({
plugins: [
createMathPlugin({ provider: mathProvider }),
createMermaidPlugin({ provider: mermaidProvider }),
],
})
Inline math: $x^2$
$$
\int_0^1 x^2 dx
$$
```math
\frac{a}{b}
```

Without @markvia/math, these remain ordinary Markdown text or code blocks.

```mermaid
graph TD
A --> B
```

Without @markvia/mermaid, Mermaid remains a regular code block.

Providers can be synchronous or asynchronous and must return structured render fragments. They must not return raw HTML. When a provider is missing or fails, Markvia displays the source in a safe code fallback.

If math is not used, do not install @markvia/math; its parser dependencies are then not installed. Neither optional package installs a rendering engine. Install the rendering engine and connect it through a provider only when rendered output is needed.