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.2.1
  • 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.

Note The interface is pretty rough. But in the future this will be built into mdast/retext, something called “bridging”, so you won’t have to use this library manually in the future :smile:!

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) {
    toNLCST(file);
    console.log(file.namespace('retext').cst);
    /*
     * 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(file[, Parser | parser])

Transform a by mdast processed virtual file into an file ready for processing by retext.

Parameters:

  • file (File) — Virtual file, must be passed through parse().

  • 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:

NLCSTNode.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 15 Aug 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