mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-05 04:19:30 +08:00
37 lines
866 B
Text
37 lines
866 B
Text
/**
|
|
* @fileoverview
|
|
* Get the plain-text value of a hast node.
|
|
* @longdescription
|
|
* ## Use
|
|
*
|
|
* ```js
|
|
* import {h} from 'hastscript'
|
|
* import {toString} from 'hast-util-to-string'
|
|
*
|
|
* toString(h('p', 'Alpha'))
|
|
* //=> 'Alpha'
|
|
* toString(h('div', [h('b', 'Bold'), ' and ', h('i', 'italic'), '.']))
|
|
* //=> 'Bold and italic.'
|
|
* ```
|
|
*
|
|
* ## API
|
|
*
|
|
* ### `toString(node)`
|
|
*
|
|
* Transform a node to a string.
|
|
*/
|
|
/**
|
|
* @typedef {import('hast').Root} Root
|
|
* @typedef {import('hast').Element} Element
|
|
* @typedef {Root|Root['children'][number]} Node
|
|
*/
|
|
/**
|
|
* Get the plain-text value of a hast node.
|
|
*
|
|
* @param {Node} node
|
|
* @returns {string}
|
|
*/
|
|
export function toString(node: Node): string
|
|
export type Root = import('hast').Root
|
|
export type Element = import('hast').Element
|
|
export type Node = Root | Root['children'][number]
|