Skip to content
Dashboard

New npm package for automatic recovery of broken streaming markdown

DX Engineer

Link to headingWhy it matters

**This is bold text
[Click here](https://exampl
`const foo = "bar

import remend from "remend";
const partialMarkdown = "This is **bold text";
const completed = remend(partialMarkdown);
// Result: "This is **bold text**"

import remend from "remend";
import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";
const streamedMarkdown = "This is **incomplete bold";
// Run Remend first to complete incomplete syntax
const completedMarkdown = remend(streamedMarkdown);
// Then process with unified
const file = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeStringify)
.process(completedMarkdown);
console.log(String(file));

npm i remend

Ready to deploy?