Skip to content

vwkd/rehype-unwrap-linebreaks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published