Markdown source highlighting

with the CSS Custom Highlight API.

npm install md-inknpm ↗
  • 0 core runtime dependencies
  • ESM + TypeScript
  • React · Vue · Svelte
hello.mdLIVE
edit me
DOM TEXT CONTAINERsame source · different CSS

Core API + CSS

Full documentation
<textarea id="source"># Hello **world**</textarea>

import { createMdInk } from 'md-ink'
const md = createMdInk(document.querySelector('#source'))

// After script value changes: md.update()
// On teardown: md.destroy()

HTML + JavaScript

SHARED CSS · ALL FRAMEWORKS
::highlight(md-ink-heading) { color: #8250df; }
::highlight(md-ink-code) {
  color: #116329; background-color: #dcfce7;
}
::highlight(md-ink-marker) { color: #8c959f; }

Core: input and DOM changes refresh automatically. Script value changes and form reset need update(); call destroy() on teardown. Recreate after target, Document or input-type changes.

Syntax & browser support

Syntax fixtures
Syntax
ATX headings, quotes, lists, bold / italic, strike, inline / fenced code and simple links. No tables, images, HTML or full CommonMark support.
Browsers
DOM: Chrome / Edge 105+, Firefox 149+, Safari / iOS 17.2+, Opera 91+, Samsung 20+. Firefox 140–148: partial. Can I Use ↗
Textarea / input: Chrome 152+ / Edge 152+ (OpaqueRange). Others stay plain.