unified

Project: rehypejs/rehype-minify

Package: hast-util-to-string@2.0.0

  1. Dependents: 83
  2. hast utility to get the plain-text value of a node
  1. util 144
  2. utility 140
  3. unist 127
  4. html 122
  5. hast 73
  6. hast-util 47
  7. content 20
  8. text 19
  9. stringify 18
  10. serialize 11
  11. string 7

hast-util-to-string

Build Coverage Downloads Size Sponsors Backers Chat

Get the plain-text value of a hast node.

Install

This package is ESM only: Node 12+ is needed to use it and it must be importeded instead of requiredd.

npm:

npm install hast-util-to-string

This package exports the following identifiers: toString. There is no default export.

Use

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.

Contribute

See contributing.md in rehypejs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer