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

nlcst-is-literal

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nlcst-is-literal

Check whether an NLCST node is meant literally

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

nlcst-is-literal Build Status Coverage Status

Check if an NLCST node is meant literally. Useful if a tool wants to exclude these values possibly void of meaning.

As an example, a spell-checker could exclude these literal words, thus not warning about “monsieur”.

Installation

npm:

npm install nlcst-is-literal

Usage

Say we have the following file, example.txt:

The word “foo” is meant as a literal.

The word «bar» is meant as a literal.

The word (baz) is meant as a literal.

The word, qux, is meant as a literal.

The word — quux — is meant as a literal.

And our script, example.js, looks as follows:

var vfile = require('to-vfile');
var unified = require('unified');
var english = require('retext-english');
var visit = require('unist-util-visit');
var toString = require('nlcst-to-string');
var literal = require('nlcst-is-literal');

var file = vfile.readSync('example.txt');
var tree = unified().use(english).parse(file);

visit(tree, 'WordNode', visitor);

function visitor(node, index, parent) {
  if (literal(parent, index)) {
    console.log(toString(node));
  }
}

Now, running node example yields:

foo
bar
baz
qux
quux

API

isLiteral(parent, index)

Check if the node in parent at position is enclosed by matching delimiters.

For example, foo is literal in the following samples:

  • Foo - is meant as a literal.
  • Meant as a literal is - foo.
  • The word “foo” is meant as a literal.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 13 Jun 2017

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