Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
mdast-util-to-nlcst
Advanced tools
mdast utility to transform markdown into nlcst, while keeping location information intact.
In plain English: this enables natural-language tooling to read markdown as input.
npm:
npm install mdast-util-to-nlcst
mdast-util-to-nlcst is also available for bower, component, and duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.
/*
* Dependencies.
*/
var mdast = require('mdast');
var toNLCST = require('mdast-util-to-nlcst');
/*
* Process.
*/
mdast.process('Some *foo*s-_ball_.', function (err, doc, file) {
var nlcst = toNLCST(file.ast, file);
/*
* Yields:
*
* Object
* ├─ type: "RootNode"
* ├─ position: Object
* | └─ start: Object
* | | ├─ line: 1
* | | ├─ column: 1
* | | └─ offset: 0
* | └─ end: Object
* | ├─ line: 1
* | ├─ column: 20
* | └─ offset: 19
* └─ children: Array[1]
* └─ 0: Object
* ├─ type: "ParagraphNode"
* ├─ position: Object
* | └─ start: Object
* | | ├─ line: 1
* | | ├─ column: 1
* | | └─ offset: 0
* | └─ end: Object
* | ├─ line: 1
* | ├─ column: 20
* | └─ offset: 19
* └─ children: Array[1]
* └─ 0: Object
* ├─ type: "SentenceNode"
* ├─ position: Object
* | └─ start: Object
* | | ├─ line: 1
* | | ├─ column: 1
* | | └─ offset: 0
* | └─ end: Object
* | ├─ line: 1
* | ├─ column: 20
* | └─ offset: 19
* └─ children: Array[4]
* ├─ 0: Object
* | ├─ type: "WordNode"
* | ├─ position: Object
* | | └─ start: Object
* | | | ├─ line: 1
* | | | ├─ column: 1
* | | | └─ offset: 0
* | | └─ end: Object
* | | ├─ line: 1
* | | ├─ column: 5
* | | └─ offset: 4
* | └─ children: Array[1]
* | └─ 0: Object
* | ├─ type: "TextNode"
* | ├─ position: Object
* | | └─ start: Object
* | | | ├─ line: 1
* | | | ├─ column: 1
* | | | └─ offset: 0
* | | └─ end: Object
* | | ├─ line: 1
* | | ├─ column: 5
* | | └─ offset: 4
* | └─ value: "Some"
* ├─ 1: Object
* | ├─ type: "WhiteSpaceNode"
* | ├─ position: Object
* | | └─ start: Object
* | | | ├─ line: 1
* | | | ├─ column: 5
* | | | └─ offset: 4
* | | └─ end: Object
* | | ├─ line: 1
* | | ├─ column: 6
* | | └─ offset: 5
* | └─ value: " "
* ├─ 2: Object
* | ├─ type: "WordNode"
* | ├─ position: Object
* | | └─ start: Object
* | | | ├─ line: 1
* | | | ├─ column: 7
* | | | └─ offset: 6
* | | └─ end: Object
* | | ├─ line: 1
* | | ├─ column: 18
* | | └─ offset: 17
* | └─ children: Array[4]
* | ├─ 0: Object
* | | ├─ type: "TextNode"
* | | ├─ position: Object
* | | | └─ start: Object
* | | | | ├─ line: 1
* | | | | ├─ column: 7
* | | | | └─ offset: 6
* | | | └─ end: Object
* | | | ├─ line: 1
* | | | ├─ column: 10
* | | | └─ offset: 9
* | | └─ value: "foo"
* | ├─ 1: Object
* | | ├─ type: "TextNode"
* | | ├─ position: Object
* | | | └─ start: Object
* | | | | ├─ line: 1
* | | | | ├─ column: 11
* | | | | └─ offset: 10
* | | | └─ end: Object
* | | | ├─ line: 1
* | | | ├─ column: 12
* | | | └─ offset: 11
* | | └─ value: "s"
* | ├─ 2: Object
* | | ├─ type: "PunctuationNode"
* | | ├─ position: Object
* | | | └─ start: Object
* | | | | ├─ line: 1
* | | | | ├─ column: 12
* | | | | └─ offset: 11
* | | | └─ end: Object
* | | | ├─ line: 1
* | | | ├─ column: 13
* | | | └─ offset: 12
* | | └─ value: "-"
* | └─ 3: Object
* | ├─ type: "TextNode"
* | ├─ position: Object
* | | └─ start: Object
* | | | ├─ line: 1
* | | | ├─ column: 14
* | | | └─ offset: 13
* | | └─ end: Object
* | | ├─ line: 1
* | | ├─ column: 18
* | | └─ offset: 17
* | └─ value: "ball"
* └─ 3: Object
* ├─ type: "PunctuationNode"
* ├─ position: Object
* | └─ start: Object
* | | ├─ line: 1
* | | ├─ column: 19
* | | └─ offset: 18
* | └─ end: Object
* | ├─ line: 1
* | ├─ column: 20
* | └─ offset: 19
* └─ value: "."
*/
});
Transform ast
(the mdast tree relating
to file
) into an nlcst node.
Parameters:
ast
(Node
)
— mdast node;
file
(File
)
— Virtual file.
parser
(Function
or Parser
, default: new ParseLatin()
, optional)
— You can pass the (constructor of) an nlcst parser, such as
parse-english or
parse-dutch, the default is
parse-latin.
Returns:
FAQs
mdast utility to transform to nlcst
The npm package mdast-util-to-nlcst receives a total of 93,186 weekly downloads. As such, mdast-util-to-nlcst popularity was classified as popular.
We found that mdast-util-to-nlcst demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.