Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@textlint/text-to-ast
Advanced tools
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 TxtNode
s.
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.
npm install @textlint/text-to-ast
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))
/*
{
"type": "Document",
"range": [
0,
32
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 17
}
},
"children": [
{
"type": "Paragraph",
"raw": "This is a text",
"range": [
0,
14
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"children": [
{
"type": "Str",
"raw": "This is a text",
"range": [
0,
14
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
}
}
]
},
{
"type": "Break",
"raw": "\n",
"range": [
14,
15
],
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
}
}
},
{
"type": "Paragraph",
"raw": "Parse text to AST",
"range": [
15,
32
],
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 17
}
},
"children": [
{
"type": "Str",
"raw": "Parse text to AST",
"range": [
15,
32
],
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 17
}
}
}
]
}
]
}
*/
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT
FAQs
Parse plain text to AST with location info.
We found that @textlint/text-to-ast demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.