Urara-Blog/node_modules/.pnpm-store/v3/files/fa/766aa0ad98ea78a332c286892871ff5fb3049bea6c384c2eacf34f64a1c8099458c78634efd1d20016f55430e2a8e87cd035fd6e021cf180eb80603443ac5e
2022-08-14 01:14:53 +08:00

31 lines
1,015 B
Text

/**
* @typedef {import('mdast').Root|import('mdast').Content} Node
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownOptions
* @typedef {Omit<ToMarkdownOptions, 'extensions'>} Options
*/
import {toMarkdown} from 'mdast-util-to-markdown'
/** @type {import('unified').Plugin<[Options]|void[], Node, string>} */
export default function remarkStringify(options) {
/** @type {import('unified').CompilerFunction<Node, string>} */
const compiler = (tree) => {
// Assume options.
const settings = /** @type {Options} */ (this.data('settings'))
return toMarkdown(
tree,
Object.assign({}, settings, options, {
// Note: this option is not in the readme.
// The goal is for it to be set by plugins on `data` instead of being
// passed by users.
extensions:
/** @type {ToMarkdownOptions['extensions']} */ (
this.data('toMarkdownExtensions')
) || []
})
)
}
Object.assign(this, {Compiler: compiler})
}