unified-conditional
v0.0.2
Published
Apply unified plugins conditionally
Downloads
5,476
Readme
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 exactlyRegExp
: Regular expression to test the filename againstfunction
: Custom match function which receives the transformer arguments and returns a boolean value