mirror of
https://github.com/Snigdha-OS/documentation.git
synced 2025-09-07 19:25:13 +02:00
31 lines
662 B
JavaScript
31 lines
662 B
JavaScript
/**
|
|
* @typedef {import('estree-jsx').Program} Program
|
|
*
|
|
* @typedef {import('hast').Root} Root
|
|
*
|
|
* @typedef {import('../core.js').ProcessorOptions} ProcessorOptions
|
|
*/
|
|
|
|
import {toEstree} from 'hast-util-to-estree'
|
|
|
|
/**
|
|
* A plugin to transform an HTML (hast) tree to a JS (estree).
|
|
* `hast-util-to-estree` does all the work for us!
|
|
*
|
|
* @param {Readonly<ProcessorOptions>} options
|
|
* Configuration (optional).
|
|
* @returns
|
|
* Transform.
|
|
*/
|
|
export function rehypeRecma(options) {
|
|
/**
|
|
* @param {Root} tree
|
|
* Tree (hast).
|
|
* @returns {Program}
|
|
* Program (esast).
|
|
*/
|
|
return function (tree) {
|
|
return toEstree(tree, options)
|
|
}
|
|
}
|