Package Exports
- mdast-util-to-string
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mdast-util-to-string) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mdast-util-to-string
mdast utility to get the plain text content of a node.
Install
This package is ESM only:
Node 12+ is needed to use it and it must be import
ed instead of require
d.
npm:
npm install mdast-util-to-string
Use
import unified from 'unified'
import remarkParse from 'remark-parse'
import {toString} from 'mdast-util-to-string'
var tree = unified()
.use(remarkParse)
.parse('Some _emphasis_, **importance**, and `code`.')
console.log(toString(tree)) // => 'Some emphasis, importance, and code.'
API
This package exports the following identifiers: toString
.
There is no default export.
toString(node)
Get the text content of a node or list of nodes.
The algorithm checks value
of node
, then alt
, and finally title
.
If no value is found, the algorithm checks the children of node
and joins them
(without spaces or newlines).
This is not a markdown to plain-text library. Use
strip-markdown
for that.
Security
Use of mdast-util-to-string
does not involve hast, user content, or
change the tree, so there are no openings for cross-site scripting (XSS)
attacks.
Related
nlcst-to-string
— Get text content in nlcsthast-util-to-string
— Get text content in hasthast-util-to-text
— Get text content in hast according to theinnerText
algorithmhast-util-from-string
— Set text content in hast
Contribute
See contributing.md
in syntax-tree/.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.