@larsbaalmans/cast-util-to-plaintext
v1.2.6
Published
This library is part of the [CAST]() abstract syntax tree utilities. It provides a utility to convert a [CAST]() abstract syntax tree directly to plaintext.
Downloads
549
Readme
cast-util-to-plaintext
This library is part of the CAST abstract syntax tree utilities. It provides a utility to convert a CAST abstract syntax tree directly to plaintext.
Usage
Using the utility cast
to plaintext looks as follows:
/**
* @import {Root} from 'cast'
*/
import {toPlaintext} from 'cast-util-to-plaintext'
/** @type {Root} */
const tree = [
{
type: 'paragraph',
children: [
{ text: 'Hello' }
]
},
{
type: 'heading',
level: 1,
children: [
{
type: 'bold',
children: [
{
type: 'text',
text: 'world'
}
]
}
]
}
]
console.info(toPlaintext(tree))
yields:
'Hello world'
Building
Run nx build cast-util-to-plaintext
to build the library.
Running unit tests
Run nx test cast-util-to-plaintext
to execute the unit tests via Vitest.