@getplate/cast-util-to-plaintext
v1.0.3
Published
Utility to convert CAST trees to plaintext.
Downloads
10
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 '@getplate/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.
