API overview
@markvia/core
Section titled “@markvia/core”import { createMarkdown, parseMarkdown, documentToIR } from '@markvia/core'
const runtime = createMarkdown({ plugins: [], highlighter,})
const document = runtime.parse(source)const ir = runtime.toIR(document)const stream = runtime.createStream()The main capabilities are:
parse(source): produce a Semantic ASTtoIR(document)/toIRAsync(document): produce Render IRrender(source, renderer): render synchronouslyrenderAsync(source, renderer): render asynchronouslycreateStream(): create an incremental Markdown streamuse(plugin): register a plugin on an existing runtime
The standalone parseMarkdown and documentToIR functions are also exported for lower-level usage.
Optional extension packages
Section titled “Optional extension packages”Math and Mermaid are not dependencies of @markvia/core. Install and register only the packages
your application needs:
pnpm add @markvia/mathpnpm add @markvia/mermaidimport { createMathPlugin } from '@markvia/math'import { createMermaidPlugin } from '@markvia/mermaid'
const runtime = createMarkdown({ plugins: [ createMathPlugin({ provider: mathProvider }), createMermaidPlugin({ provider: mermaidProvider }), ],})If math is not used, omit @markvia/math so its parser dependencies are not installed.
Neither optional package installs a rendering engine. Providers return structured Render fragments,
support sync and async rendering, and fall back to safe source code when unavailable.
@markvia/shiki
Section titled “@markvia/shiki”import { createShikiHighlighter } from '@markvia/shiki'
const highlighter = await createShikiHighlighter({ theme: 'vitesse-dark' })const runtime = createMarkdown({ highlighter })const html = await runtime.renderAsync(source, htmlRenderer)The adapter dynamically loads and caches built-in languages. Missing or unknown languages use plain text fallback.
HTML renderer
Section titled “HTML renderer”import { htmlRenderer, createHTMLRenderer } from '@markvia/html'
const html = runtime.render(source, htmlRenderer)const compatibleHtml = runtime.render(source, createHTMLRenderer({ allowRawHtml: true }))htmlRenderer escapes raw HTML by default. allowRawHtml is an HTML-renderer compatibility option; React and Vue always output raw HTML as safe text.
React renderer
Section titled “React renderer”import { Markdown, createReactRenderer, renderReact } from '@markvia/react'
const reactNode = renderReact(ir)const renderer = createReactRenderer({ components })
function Article() { return <Markdown content={source} />}Vue renderer
Section titled “Vue renderer”<script setup lang="ts">import { Markdown } from '@markvia/vue'</script>
<template> <Markdown :content="source" /></template>