unified-conditional

0.0.2 • Public • Published

unified-conditional

Apply unified plugins conditionally

Usage

import { remark } from 'remark'
import { VFile } from 'vfile'
import { unifiedConditional } from 'unified-conditional'

let options = [
  // Pattern to match
  /example\.md$/,
  // Plugins to run if pattern matches
  [/* ... */],
  // Plugins to run if pattern does not match
  [/* ... */],
]

await remark()
  .use(unifiedConditional, options)
  .process(new VFile({ path: '/example.md', value: '# Hello world' }))

The pattern can be one of three types:

  • string: String value to match the filename against exactly
  • RegExp: Regular expression to test the filename against
  • function: Custom match function which receives the transformer arguments and returns a boolean value

Package Sidebar

Install

npm i unified-conditional

Weekly Downloads

1,533

Version

0.0.2

License

MIT

Unpacked Size

3.42 kB

Total Files

4

Last publish

Collaborators

  • bradlc