Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mdast-util-to-nlcst

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-to-nlcst

Markdown to Natural Language

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
111K
decreased by-7.39%
Maintainers
1
Weekly downloads
 
Created
Source

mdast-util-to-nlcst Build Status Coverage Status

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.

Installation

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.

Usage

/*
 * 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: "."
     */
});

API

toNLCST(ast, file[, Parser | parser])

Transform ast (the mdast tree relating to file) into an nlcst node.

Parameters:

Returns:

NLCSTNode.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 25 Jul 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc