Repository navigation
v0.10.0 is the next major release.
⚠️ Breaking changes
v0.10.0 makes Comark safe by default for content you don't control, keeps optional runtimes out of the core install, and makes the framework renderers behave the same way.
1. security() runs by default (#660)
parseMarkdown(), createMarkdownParser() and every framework <Markdown> component now run security() after your own plugins. It removes event handler attributes (onclick, onerror, ...), javascript: and other unsafe URLs, markup props (innerHTML, *-html bindings), and bound as / is selectors.
Why: Comark mostly renders text its developers didn't write: LLM output, CMS fields, user comments. Until now handlers and javascript: URLs reached the page unless every app remembered to opt in. Sanitizing in the parser means it happens once, the same way for every renderer, and also covers nodes added by your plugins' post hooks. Raw HTML stays on because GFM depends on it (<details>, <kbd>).
To avoid deleting harmless data such as online: true, one: 1 or bodyHtml, an attribute now counts as a handler only when it is on plus a real DOM event name (or a vendor prefix like onwebkit…). Frontmatter keys ending in Html are kept as data.
Migration:
- Customize: pass your own
security({ ... }). It replaces the default. - Opt out (trusted content only):
registerDefaultPlugins: falsewith the plugins you want, orcomark/core. <script>,<iframe>and similar still needblockedTags, whose default is still empty.
Cost: about +4.5 KB gzipped on the default entry. Non-streaming parses are 15% to 2× slower depending on HTML attribute density. Streaming barely changes, because already-sanitized blocks are skipped.
2. Optional plugins moved into their own packages (#649)
| Before | After |
|---|---|
comark/plugins/math, @comark/*/plugins/math |
@comark/plugin-katex (+ framework entries, /katex.css) |
comark/plugins/mermaid, @comark/*/plugins/mermaid |
@comark/plugin-beautiful-mermaid (+ framework entries) |
comark/plugins/shiki |
@comark/plugin-shiki (., /core, /language-comark) |
comark/plugins/rangi |
@comark/plugin-rangi (., /language-comark) |
comark/plugins/pierre-highlights |
@comark/plugin-pierre-highlights |
comark/plugins/highlight (deprecated) |
removed, use @comark/plugin-shiki |
- import math, { Math } from '@comark/vue/plugins/math'
+ import math from '@comark/plugin-katex'
+ import { Math } from '@comark/plugin-katex/vue'Why: comark and every renderer declared katex, beautiful-mermaid, shiki, rangi and @pierre/highlights as optional peers. Installing a plugin took two steps, most apps saw peer warnings for runtimes they never used, and the parser tarball shipped highlighter code. Each package now depends on its runtime directly, so one npm install @comark/plugin-x is enough. renderMarkdown() still writes mermaid fences back without the plugin.
Migration: install the packages you use, update imports, and drop runtimes you only had as Comark peers. Old docs URLs redirect to /plugins/official/*.
3. The caret prop is replaced by effects (#623)
Markdown and MarkdownDocument in Vue, React, Svelte and Angular no longer accept caret. Streaming visuals go through one effects prop with caret(), fade(), typewriter() and pace() from comark/effects.
- <Markdown :markdown="text" caret />
+ <Markdown :markdown="text" :effects="[caret()]" />React / Svelte: effects={[caret()]}. Angular: [effects]="effects" with effects = [caret()].
Why: a boolean prop per effect would keep growing four renderer APIs and couldn't express order or options. One ordered array composes effects ([pace(), fade(), caret()]), is implemented once in comark/effects so it behaves the same everywhere, and accepts custom effects. A deprecated caret alias would have meant two code paths in each renderer, so it was removed outright.
4. Angular: Angular 21+, signal inputs, ng-packagr, named exports (#446)
- Minimum Angular goes from 17 to 21 (peer range
>=21 <23). - Components use signal inputs (
input()),inject()andcomputed(). - Built with
ng-packagrin the Angular Package Format, published fromdist/. - Plugin entry points use named exports:
- import binding, { Binding, If } from '@comark/angular/plugins/binding'
+ import { binding, Binding, If } from '@comark/angular/plugins/binding'Math and Mermaid for Angular now come from @comark/plugin-katex/angular and @comark/plugin-beautiful-mermaid/angular.
Why: signal inputs are the current Angular model and react to input changes without lifecycle hooks. The hand-rolled ngc build didn't follow the Angular Package Format. ng-packagr enforces it and strips export default from entry points by design, so named exports are required (they also help tree-shaking and Ivy's static analysis). Supporting both input styles on Angular 17–20 would have doubled the component surface.
Migration: upgrade to Angular 21+, switch to named imports. Templates don't change. For AOT builds, prefer provideMarkdown() / provideMarkdownDocument() (#614) over the defineMarkdownComponent() factories.
5. parseFrontmatter is no longer exported from comark (#633)
- import { parseFrontmatter } from 'comark'
+ import { parseFrontmatter } from 'comark/plugins/frontmatter'
+ // or, for plain YAML:
+ import { parseYaml, stringifyYaml } from 'comark/utils/yaml'Why: frontmatter is a plugin, so its helpers belong with it instead of tying the root API to a YAML implementation. renderFrontmatter is still exported from comark/render, and libraries that only need YAML get a stable comark/utils/yaml entry instead of reaching into internals.
Behavior changes listed under Fixes
Not API breaks, but they change output, so check AST or HTML snapshots:
asandisonly accept plain tag names, andsecurity()treats them as the element's tag (#598, #603).- Tight list items no longer wrap their content in a paragraph node (#648).
Upgrading
- Install the
@comark/plugin-*packages you use and update imports. - Replace
caretwitheffects={[caret()]}. - Angular: upgrade to 21+ and use named plugin imports.
- Import
parseFrontmatterfromcomark/plugins/frontmatter. - Check that the default
security()doesn't remove anything you rely on.
👉 Changelog
🚀 Enhancements
⚠️ runsecurity()by default and match only real event handlers (#660)⚠️ extract official plugins into their own packages (#649)- angular: add AOT-safe provideMarkdown helpers (#614)
⚠️ introduce streaming effects (#623)- plugins: add
pierre-highlightsplugin (#612) - plugins: add
external-linksplugin (#599) ⚠️ angular: migrate to signal inputs and ng-packagr (#446)
🔥 Performance
- react,core: memoize top-level nodes and skip reused prefix in security (#641)
- vue: keep the parser out of defineMarkdownDocumentComponent (#632)
🩹 Fixes
- auto-close: ignore raw-text tags inside code fences (#659)
- parse: preserve token attributes on code block pre nodes (#662)
- vue: yield parse auto-imports to @nuxtjs/mdc (#656)
- parse: preserve empty ATX headings (#653)
- parse: drop paragraph wrappers in tight list items (#648)
- plugins: keep footnote definitions inside fenced code (#650)
- highlight: let highlighted lines span the full code block row (#647)
- parse: support unknown _open/_close markdown-it plugin tokens (#638)
- auto-close: keep links open until their real closing parenthesis (#645)
- autoclose: keep emphasis with inner whitespace closing cleanly (#644) (#644, #646)
- parse: keep non-numeric fence braces out of highlights (#643)
- parse: avoid stack overflow when building nodes with many children (#635)
- alert: skip unchanged prefix nodes while streaming (#620)
- parse: preserve empty image alt attributes (#630)
- utils: anchor numeric entity check in escapeHtml (#629)
- utils: leave HTML comments out of text content (#621)
- angular: avoid NG0503 during SSR hydration serialization (#618)
- parse: ignore closing fences indented 4+ spaces inside components (#605)
- math: load KaTeX lazily and show TeX source when it can't typeset (#514)
- render: keep binding props in markdown/html (#607)
- keep text after an unclosed
{and documents with broken frontmatter (#570) - render: keep blank lines around markdown inside raw html (#617)
- shiki: tokenize an unchanged fence once while a document streams (#616)
- stringify: keep lists, nested emphasis and multi-line headings on round trip (#604)
- render: keep markdown inside components in markdown/html (#606)
- parse: auto-unwrap default slot content next to named slots (#611)
- svelte: create SVG and MathML elements in their namespaces (#602)
- security: treat
asandisas the element's tag (#603) - only allow plain tag names in
asandis(#598) - vue: register Nuxt components from their own entries (#600)
- components: parse adjacent footnote references (#594)
- autoclose: do not close underscore emphasis after punctuation (#593)
💅 Refactors
⚠️ move frontmatter helpers into plugin and expose comark/utils/yaml (#633)
📖 Documentation
- fix migration skill install command (#664)
- clean up AI-written prose in docs and comments (#609)
- fix parser options table formatting (#588)
🏡 Chore
✅ Tests
- svelte: run browser tests in ci (#619)
- add regression tests for
$tokens without math plugin (#136) (#136, #615)
🎉 New Contributors
- Jonas Thelemann (@dargmuesli)
- Enes Kartal (@EnesKartal)
- Adrián UB (@adrian-ub)
- Aariv Patel (@draarivpatel-ui)
- Abhishek Sharma (@abhiishek-sharma)
- shiguri (@shiguri-01)
❤️ Contributors
- Farnabaz (@farnabaz)
- Max (@onmax)
- Sébastien Chopin (@atinux)
- Jonas Thelemann (@dargmuesli)
- Baptiste Leproux (@larbish)
- Enes Kartal (@EnesKartal)
- Adrián UB (@adrian-ub)
- Aariv Patel (@draarivpatel-ui)
- Abhishek Sharma (@abhiishek-sharma)
- Ali Assar (@aliassar)
- Benjamin Canac (@benjamincanac)
- shiguri (@shiguri-01)