UnifiedJS Turns Any Text Format Into a Parse-Transform-Generate Pipeline
Content conversion in frontend projects usually means gluing together single-purpose libraries with ad-hoc logic. UnifiedJS replaces that with a composable pipeline where the same AST manipulation works across Markdown, HTML, and JSX, so a custom transform written once applies everywhere.
UnifiedJS treats every text format as an abstract syntax tree, making Markdown-to-HTML, stripping formatting, or adding code highlighting a matter of swapping plugins in a single pipeline. The framework's core is a parse-transform-stringify flow: remark-parse builds a Markdown AST, plugins like strip-markdown or rehype-highlight mutate it, and a stringifier outputs the target format.
Three hands-on cases walk through removing all Markdown formatting to plain text, converting Markdown to syntax-highlighted HTML, and building a Vue 3 real-time preview component. Each case shows the exact npm installs and pipeline assembly, with synchronous processing for small texts and Web Worker chunking for documents over 100,000 words.
Advanced patterns include caching the processor instance for a 40% speedup under frequent re-renders, and assembling plugin chains for specific domains like component-library docs (auto-TOC, slug anchors, image lazy-loading) or WeChat Official Account formatting with watermark injection and mobile width constraints.
UnifiedJS's real power is that the AST is format-agnostic; a transform written for Markdown nodes can often be reused on HTML nodes with minimal adjustment, collapsing what would otherwise be separate conversion scripts.
The framework's plugin granularity means performance tuning is explicit — caching the processor, choosing sync vs. async, and deciding when to spawn a Worker are all developer-controlled, not hidden behind a black-box API.
Strip-markdown is a better default than hand-rolled regex because it tracks the Markdown spec; custom regex solutions silently break on footnotes, nested formatting, or edge-case table syntax that the plugin already handles.