Skip to content

Latest commit

 

History

History
39 lines (25 loc) · 696 Bytes

README.md

File metadata and controls

39 lines (25 loc) · 696 Bytes

README

Rehype plugin that unwraps leading and trailing line breaks <br> from inline nodes

Features

  • unwraps leading and trailing line breaks <br> from inline nodes
  • inline nodes currently used: <em>, <strong>, <a>

Example

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