Skip to content
Utility to get the plain text content of a node
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.gitignore
.npmrc
.prettierignore
.travis.yml
index.js
license
package.json
readme.md
test.js

readme.md

mdast-util-to-string Build Coverage Downloads Chat

Get the plain text content of mdast nodes.

Installation

npm:

npm install mdast-util-to-string

Usage

var unified = require('unified')
var parse = require('remark-parse')
var toString = require('mdast-util-to-string')

var tree = unified()
  .use(parse)
  .parse('Some _emphasis_, **importance**, and `code`.')

console.log(toString(tree)) // => 'Some emphasis, importance, and code.'

API

toString(node)

Get the text content of a node.

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.

Related

Contribute

See contributing.md in syntax-tree/mdast for ways to get started.

This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer

You can’t perform that action at this time.