breaks()

Convert newlines in text to `<br>` elements.

import { breaks } from "@unifast/node";

Signature

function breaks(): UnifastPlugin

Parameters

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> element

Examples

Newlines to line breaks

Without breaks(), these three lines would merge into a single paragraph. With the plugin enabled, each newline becomes a <br>: