🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
36
node_modules/hast-util-to-html/lib/handle/text.js
generated
vendored
Normal file
36
node_modules/hast-util-to-html/lib/handle/text.js
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').Raw} Raw
|
||||
* @typedef {import('../types.js').Text} Text
|
||||
*/
|
||||
|
||||
import {stringifyEntities} from 'stringify-entities'
|
||||
|
||||
/**
|
||||
* Serialize a text node.
|
||||
*
|
||||
* @param {Text | Raw} node
|
||||
* Node to handle.
|
||||
* @param {number | undefined} _
|
||||
* 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 text(node, _, parent, state) {
|
||||
// Check if content of `node` should be escaped.
|
||||
return parent &&
|
||||
parent.type === 'element' &&
|
||||
(parent.tagName === 'script' || parent.tagName === 'style')
|
||||
? node.value
|
||||
: stringifyEntities(
|
||||
node.value,
|
||||
Object.assign({}, state.settings.characterReferences, {
|
||||
subset: ['<', '&']
|
||||
})
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue