kjelsrud.dev/node_modules/hast-util-to-html/lib/handle/raw.js
2023-07-19 21:31:30 +02:00

27 lines
659 B
JavaScript

/**
* @typedef {import('../types.js').State} State
* @typedef {import('../types.js').Parent} Parent
* @typedef {import('../types.js').Raw} Raw
*/
import {text} from './text.js'
/**
* Serialize a raw node.
*
* @param {Raw} node
* Node to handle.
* @param {number | undefined} index
* Index of `node` in `parent.
* @param {Parent | undefined} parent
* Parent of `node`.
* @param {State} state
* Info passed around about the current state.
* @returns {string}
* Serialized node.
*/
export function raw(node, index, parent, state) {
return state.settings.allowDangerousHtml
? node.value
: text(node, index, parent, state)
}