<commit_before># nlcst-is-literal [![Build Status](https://img.shields.io/travis/wooorm/nlcst-is-literal.svg)](https://travis-ci.org/wooorm/nlcst-is-literal) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/nlcst-is-literal.svg)](https://codecov.io/github/wooorm/nlcst-is-literal)

Check whether 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](https://docs.npmjs.com/cli/install):

```bash
npm install nlcst-is-literal
```

## Usage

```javascript
var retext = require('retext');
var visit = require('unist-util-visit');
var toString = require('nlcst-to-string');
var isLiteral = require('.');

retext().use(function () {
  return function (cst) {
    visit(cst, 'WordNode', function (node, index, parent) {
      if (isLiteral(parent, index)) {
        console.log(toString(node));
      }
    });
  }
}).process([
  '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.'
].join('\n\n'));
```

Yields:

```text
foo
bar
baz
qux
quux
```

## API

### isLiteral(parent, index)

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

For example, in:

*   `Foo - is meant as a literal.`;
*   `Meant as a literal is - foo.`;
*   `The word “foo” is meant as a literal.`;

...`foo` is literal.

###### Parameters

*   `node` ([`NLCSTParentNode`](https://github.com/wooorm/nlcst#parent))
    — Parent to search.

*   `nodes` (`Array.<NLCSTNode>`) — Position of node to check.

###### Returns

`boolean` — Whether the node is literal.

**Throws**

*   `Error` — When no parent node is given;
*   `Error` — When no index is given.

## License

[MIT](LICENSE) © [<NAME>](http://wooorm.com)<commit_msg>Refactor docs<commit_after># nlcst-is-literal [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]

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][]:

```bash
npm install nlcst-is-literal
```

## Usage

```javascript
var retext = require('retext');
var visit = require('unist-util-visit');
var toString = require('nlcst-to-string');
var literal = require('nlcst-is-literal');

retext().use(plugin).process([
  '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.'
].join('\n\n'));

function plugin() {
  return transformer;
  function transformer(tree) {
    visit(tree, 'WordNode', visitor);
  }
  function visitor(node, index, parent) {
    if (literal(parent, index)) {
      console.log(toString(node));
    }
  }
}
```

Yields:

```text
foo
bar
baz
qux
quux
```

## API

### `isLiteral(parent, index)`

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

For example, in:

*   `Foo - is meant as a literal.`;
*   `Meant as a literal is - foo.`;
*   `The word “foo” is meant as a literal.`;

...`foo` is literal.

## License

[MIT][license] © [<NAME>][author]

<!-- Definitions -->

[travis-badge]: https://img.shields.io/travis/wooorm/nlcst-is-literal.svg

[travis]: https://travis-ci.org/wooorm/nlcst-is-literal

[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/nlcst-is-literal.svg

[codecov]: https://codecov.io/github/wooorm/nlcst-is-literal

[npm]: https://docs.npmjs.com/cli/install

[license]: LICENSE

[author]: http://wooorm.com
{'fraction_non_alphanumeric': 0.1696058091286307, 'fraction_numerical': 0.0, 'mean_word_length': 3.82125, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 11, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '160631', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1371, 'n_words': 407}