This commit is contained in:
43
node_modules/remark-rehype/index.js
generated
vendored
Normal file
43
node_modules/remark-rehype/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict'
|
||||
|
||||
var mdast2hast = require('mdast-util-to-hast')
|
||||
|
||||
module.exports = remark2rehype
|
||||
|
||||
// Attacher.
|
||||
// If a destination is given, runs the destination with the new hast tree
|
||||
// (bridge mode).
|
||||
// Without destination, returns the tree: further plugins run on that tree
|
||||
// (mutate mode).
|
||||
function remark2rehype(destination, options) {
|
||||
if (destination && !destination.process) {
|
||||
options = destination
|
||||
destination = null
|
||||
}
|
||||
|
||||
return destination ? bridge(destination, options) : mutate(options)
|
||||
}
|
||||
|
||||
// Bridge mode.
|
||||
// Runs the destination with the new hast tree.
|
||||
function bridge(destination, options) {
|
||||
return transformer
|
||||
|
||||
function transformer(node, file, next) {
|
||||
destination.run(mdast2hast(node, options), file, done)
|
||||
|
||||
function done(err) {
|
||||
next(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mutate-mode.
|
||||
// Further transformers run on the hast tree.
|
||||
function mutate(options) {
|
||||
return transformer
|
||||
|
||||
function transformer(node) {
|
||||
return mdast2hast(node, options)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user