unified

Project: retextjs/retext-syntax-mentions

Package: retext-syntax-mentions@3.1.0

  1. Dependents: 4
  2. retext plugin to classify @mentions as syntax, not natural language
  1. unified 174
  2. plugin 137
  3. retext 37
  4. syntax 27
  5. retext-plugin 24
  6. github 9
  7. source 3
  8. mention 2
  9. twitter 2

retext-syntax-mentions

Build Coverage Downloads Size Sponsors Backers Chat

retext plugin to classify @mentions as syntax, not natural language.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install retext-syntax-mentions

Use

Without syntax-mentions:

import dictionary from 'dictionary-en-gb'
import {reporter} from 'vfile-reporter'
import {unified} from 'unified'
import retextEnglish from 'retext-english'
import retextSyntaxMentions from 'retext-syntax-mentions'
import retextSpell from 'retext-spell'
import retextStringify from 'retext-stringify'

unified()
  .use(retextEnglish)
  .use(retextSpell, dictionary)
  .use(retextStringify)
  .process('Misspelt? @wooorm.')
  .then((file) => {
    console.log(reporter(file))
  })

Yields:

  1:12-1:18  warning  `wooorm` is misspelt; did you mean `worm`?  retext-spell  retext-spell

⚠ 1 warning

With syntax-mentions:

   .use(retextEnglish)
+  .use(retextSyntaxMentions)
   .use(retextSpell, dictionary)

Yields:

no issues found

API

This package exports no identifiers. The default export is retextSyntaxMentions.

unified().use(retextSyntaxMentions[, options])

Classify @mentions as source, which represent “external (ungrammatical) values” instead of natural language. This hides mentions from retext-spell, retext-readability, retext-equality, and more.

options.style

Style can be either 'github' (for GitHub user and team mentions), 'twitter' (for Twitter handles), or a regular expression (such as /^@\w{1,15}$/i, which is the Twitter regex).

Contribute

See contributing.md in retextjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer