retext-syntax-mentions

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

Usage no npm install needed!

<script type="module">
  import retextSyntaxMentions from 'https://cdn.skypack.dev/retext-syntax-mentions';
</script>

README

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).

Related

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