Skip to content

Commit

Permalink
Fix support for explicit nullish processor
Browse files Browse the repository at this point in the history
Closes GH-21.
  • Loading branch information
wooorm committed Oct 3, 2021
1 parent 2e2401a commit b718673
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -26,12 +26,12 @@ import {toHast} from 'mdast-util-to-hast'
* Options passed to `mdast-util-to-hast`.
*/
const remarkRehype =
/** @type {(import('unified').Plugin<[Processor, Options?]|[Options]|[], MdastRoot>)} */
/** @type {(import('unified').Plugin<[Processor, Options?]|[null|undefined, Options?]|[Options]|[], MdastRoot>)} */
(
function (destination, options) {
return destination && 'run' in destination
? bridge(destination, options)
: mutate(destination)
: mutate(destination || options)
}
)

Expand Down
11 changes: 11 additions & 0 deletions test.js
Expand Up @@ -28,6 +28,17 @@ test('remarkRehype', (t) => {
'should mutate with options'
)

t.equal(
unified()
.use(remarkParse)
.use(remarkRehype, null, {allowDangerousHtml: true})
.use(rehypeStringify, {allowDangerousHtml: true})
.processSync('## Hello, <i>world</i>! ##')
.toString(),
'<h2>Hello, <i>world</i>!</h2>',
'should mutate with `processor: null` and options'
)

t.equal(
unified()
.use(remarkParse)
Expand Down

0 comments on commit b718673

Please sign in to comment.