breaks()
Convert newlines in text to `<br>` elements.
import { breaks } from "@unifast/node";Signature
function breaks(): UnifastPluginParameters
None.
Usage
import { compile, breaks } from "@unifast/node";
const md = `This is line one.
This is line two.
This is line three.`;
const result = compile(md, {
plugins: [breaks()],
});
// Each newline becomes a <br> elementExamples
Newlines to line breaks
Without breaks(), these three lines would merge into a single paragraph. With the plugin enabled, each newline becomes a <br>: