Rehype plugin that unwraps leading and trailing line breaks <br>
from inline nodes
- unwraps leading and trailing line breaks
<br>
from inline nodes - inline nodes currently used:
<em>
,<strong>
,<a>
import { unified, rehypeParse, rehypeStringify } from "./deps.ts";
import rehypeUnwrap from "./src/main.ts";
const result = (await unified()
.use(rehypeParse, { fragment: true })
.use(rehypeUnwrapLinebreak)
.use(rehypeStringify)
.process(`<div><span><strong>Lorem ipsum<br></strong></span></div>`))
.toString();
console.log(result);
Before
<strong>foo </strong>bar
After
<strong>foo</strong> bar