site/node_modules/retext-stringify/lib/index.js
2024-10-14 08:09:33 +02:00

28 lines
627 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('nlcst').Root} Root
*/
import {toString} from 'nlcst-to-string'
/**
* Add support for serializing natural language.
*
* @returns {undefined}
* Nothing.
*/
export default function retextStringify() {
// eslint-disable-next-line unicorn/no-this-assignment
const self =
/** @type {import('unified').Processor<undefined, undefined, undefined, Root, string>} */ (
// @ts-expect-error -- TS in JSDoc doesnt understand `this`.
this
)
self.compiler = compiler
}
/** @type {import('unified').Compiler<Root, string>} */
function compiler(tree) {
return toString(tree)
}