Urara-Blog/node_modules/.pnpm-store/v3/files/89/112fc70587cfe8048732b72e21a377070d19cb0c419e8204470b06a5c0a69b166e9c3ac469216494b43f123bfd885beaae643adca5a6c56174229092cd31f5
2022-08-14 01:14:53 +08:00

28 lines
899 B
Text

/**
* @typedef {import('mdast').Root} Root
* @typedef {import('mdast-util-from-markdown').Options} Options
*/
import {fromMarkdown} from 'mdast-util-from-markdown'
/** @type {import('unified').Plugin<[Options?] | void[], string, Root>} */
export default function remarkParse(options) {
/** @type {import('unified').ParserFunction<Root>} */
const parser = (doc) => {
// Assume options.
const settings = /** @type {Options} */ (this.data('settings'))
return fromMarkdown(
doc,
Object.assign({}, settings, options, {
// Note: these options are not in the readme.
// The goal is for them to be set by plugins on `data` instead of being
// passed by users.
extensions: this.data('micromarkExtensions') || [],
mdastExtensions: this.data('fromMarkdownExtensions') || []
})
)
}
Object.assign(this, {Parser: parser})
}