marked-to-comark
A codemod and checker that moves a marked project to Comark and says what it leaves to you.
Install the global Vite+ CLI before running this command. Without it, replace vp dlx with pnpm dlx.
marked-to-comark moves a project from marked to Comark. It changes only what marked would still render the same, and reports the rest with a fix.
Features
Section titled "Features"checklists every marked setup it finds, with a fix for each problem.rewriteswapsmarked.parse(md)for Comark'srenderHtmlwhen every option and extension carries over.contentescapes the Markdown Comark would read differently.- It finds the shared
marked,new Marked()instances,marked.use()andsetOptions(), and the calls in JavaScript, TypeScript, Vue, Svelte, and Astro files. - It reads the marked version each package declares, so heading ids, tabs, and tables from older versions carry over.
- It also runs in Vite Doctor.
Tested on 100 projects.
Why Comark
Section titled "Why Comark"Comark parses Markdown into a document you can render to Vue, React, Svelte, Angular, HTML, or the terminal, with components written in plain-text Markdown. Many marked projects render a model's reply as it streams in; Comark completes the unfinished Markdown at every step, so a half-written **bold or code fence renders right away instead of as raw asterisks.
Try the check without installing anything. It only reads the project:
pnpm dlx marked-to-comark check .The whole migration is four commands. Getting started explains each one.
pnpm marked-to-comark check .
pnpm marked-to-comark content "posts/**/*.md" --write
pnpm marked-to-comark rewrite . --write
pnpm marked-to-comark check .Limits
Section titled "Limits"- Comark renders asynchronously. A call inside a function that isn't async stays, since making it async changes the function's callers.
- A custom
renderer,tokenizer,walkTokens, orhooksis your code. The check names what each becomes in Comark, but you port it. - Most marked projects render strings at runtime, such as chat replies or CMS fields. Those need no changes.
contentis for Markdown files marked reads from the repository. - It leaves a block as written when no edit keeps marked's output the same, and reports it as MKC0303.