@textlint/text-to-ast
Parse plain text to AST with location info.
This library is a part of textlint/textlint.
Markdown version: @textlint/markdown-to-ast
The AST consists of TxtNodes.
A TxtNode of the AST has following properties:
loc - Nodes have line and column-based location info.
range - Nodes have an index-based location range (array).
raw - Node have a raw text.
value - Node have a value of text.
The interface are defined in textlint/txtnode.md
This library is a part of textlint/textlint.
Installation
npm install @textlint/text-to-ast
DEMO
Usage
var parse = require("@textlint/text-to-ast").parse;
var text = "This is a text\nParse text to AST";
var AST = parse(text);
console.log(JSON.stringify(AST, null ,4))
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT