@stefanprobst/unified-util-bridge
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

unified-util-bridge

unified plugin to process a tree in "bridge mode" and expose the result on a data property on the original processor's VFile.

How to install

yarn add @stefanprobst/unified-util-bridge

How to use

The plugin takes two required parameters: the name of the VFile data property, and a unified processor (compiler and transformers).

import { unified } from 'unified'
import fromMarkdown from 'remark-parse'
import toMarkdown from 'remark-stringify'
import strip from 'strip-markdown'
import bridge from '@stefanprobst/unified-util-bridge'
import toHast from 'remark-rehype'
import toHtml from 'rehype-stringify'

const content = '**This** is *some* text.'

const processor = unified()
  .use(fromMarkdown)
  .use(bridge, 'plaintext', unified().use(strip).use(toMarkdown))
  .use(toHast)
  .use(toHtml)
const file = processor.processSync(content)
console.log(String(file)) // markdown transformed to html
console.log(file.data.plaintext) // markdown transformed to plaintext

Readme

Keywords

none

Package Sidebar

Install

npm i @stefanprobst/unified-util-bridge

Weekly Downloads

2

Version

2.0.1

License

MIT

Unpacked Size

4.59 kB

Total Files

5

Last publish

Collaborators

  • stefanprobst