kjelsrud.dev/node_modules/rehype-raw/index.js
2023-07-19 21:31:30 +02:00

21 lines
613 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @typedef {import('hast').Root} Root
* @typedef {import('hast-util-raw').Options} Options
* @typedef {import('hast-util-raw')} DoNotTouchAsThisImportIncludesRawInTree
*/
import {raw} from 'hast-util-raw'
/**
* Plugin to parse the tree again (and raw nodes).
* Keeping positional info OK. 🙌
*
* @type {import('unified').Plugin<[Options?] | Array<void>, Root>}
*/
export default function rehypeRaw(options = {}) {
return (tree, file) => {
// Assume that when a root was given, its also returned.
const result = /** @type {Root} */ (raw(tree, file, options))
return result
}
}