Skip to content

Commit d253029

Browse files
committed
Add nlcst to “Syntax trees in TS”
1 parent f087beb commit d253029

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

doc/learn/syntax-trees-typescript.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This guide will introduce you to using unist and unified with TypeScript.
2828
* [mdast (markdown)](#mdast-markdown)
2929
* [hast (HTML)](#hast-html)
3030
* [xast (XML)](#xast-xml)
31+
* [nlcst (Natural language)](#nlcst-natural-language)
3132
* [Summary](#summary)
3233
* [Next steps](#next-steps)
3334

@@ -311,6 +312,33 @@ To import the types in [JSDoc TypeScript][ts-jsdoc], use:
311312
*/
312313
```
313314

315+
### nlcst (Natural language)
316+
317+
[nlcst][] extends unist with types specific for natural language such as
318+
`Sentence`, `Word`, and many more.
319+
The specification includes a full list of nodes.
320+
The types are available in a types only package: [`@types/nlcst`][ts-nlcst].
321+
322+
Install:
323+
324+
```sh
325+
npm install --save-dev @types/nlcst
326+
```
327+
328+
To import the types into a TypeScript file, use:
329+
330+
```ts twoslash
331+
import type {Paragraph, Sentence, Word, Root} from 'nlcst'
332+
```
333+
334+
To import the types in [JSDoc TypeScript][ts-jsdoc], use:
335+
336+
```js twoslash
337+
/**
338+
* @import {Paragraph, Sentence, Word, Root} from 'nlcst'
339+
*/
340+
```
341+
314342
### Summary
315343

316344
* unified provides types for each language’s syntax tree
@@ -330,6 +358,8 @@ To import the types in [JSDoc TypeScript][ts-jsdoc], use:
330358

331359
[hast]: https://github.com/syntax-tree/hast
332360

361+
[nlcst]: https://github.com/syntax-tree/nlcst
362+
333363
[xast]: https://github.com/syntax-tree/xast#readme
334364

335365
[ts-unist]: https://www.npmjs.com/package/@types/unist
@@ -338,6 +368,8 @@ To import the types in [JSDoc TypeScript][ts-jsdoc], use:
338368

339369
[ts-hast]: https://www.npmjs.com/package/@types/hast
340370

371+
[ts-nlcst]: https://www.npmjs.com/package/@types/nlcst
372+
341373
[ts-xast]: https://www.npmjs.com/package/@types/xast
342374

343375
[ts-jsdoc]: https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html

0 commit comments

Comments
 (0)