retext-syntax-mentions

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

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
retext-syntax-mentions
4.0.06 months ago8 years agoMinified + gzip package size for retext-syntax-mentions in KB

Readme

retext-syntax-mentions
!Buildbuild-badgebuild !Coveragecoverage-badgecoverage !Downloadsdownloads-badgedownloads !Sizesize-badgesize !Sponsorssponsors-badgecollective !Backersbackers-badgecollective !Chatchat-badgechat
retext plugin to classify @mentions as syntax instead of natural language.

Contents

*   [`unified().use(retextSyntaxMentions[, options])`](#unifieduseretextsyntaxmentions-options)
*   [`Options`](#options)

What is this?

This package is a unified
(retext) plugin to classify mentions (as used on for example GitHubmention) as SourceNodenlcst-source instead of natural language. That node represent “external (ungrammatical) values” instead of natural language, which hides mentions from retext-spellretext-spell, retext-readabilityretext-readability, retext-equalityretext-equality, and other things that check words.

When should I use this?

You can use this plugin any time there are mentions in prose, that are (incorrectly) warned about by linting plugins.

Install

This package is ESM onlyesm. In Node.js (version 16+), install with npm:
npm install retext-syntax-mentions

In Deno with esm.shesmsh:
import retextSyntaxMentions from 'https://esm.sh/retext-syntax-mentions@4'

In browsers with esm.shesmsh:
<script type="module">
  import retextSyntaxMentions from 'https://esm.sh/retext-syntax-mentions@4?bundle'
</script>

Use

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

const file = await unified()
  .use(retextEnglish)
  .use(retextSpell, dictionaryEn)
  .use(retextStringify)
  .process('Misspelled? @wooorm.')

console.log(reporter(file))

Yields:
1:14-1:20 warning `wooorm` is misspelt; did you mean `worm`? wooorm retext-spell

⚠ 1 warning

With retext-syntax-mentions:
.use(retextEnglish)
+  .use(retextSyntaxMentions)
.use(retextSpell, dictionaryEn)

Yields:
no issues found

API

This package exports no identifiers. The default export is retextSyntaxMentionsapi-retext-syntax-mentions.

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

Classify @mentions as source (external ungrammatical values) instead of natural language.
This hides mentions from retext-spell, retext-readability, retext-equality, etc.
Parameters
— configuration
Returns
Transform (Transformerunified-transformer).

Options

Configuration (TypeScript type).
Fields
  • style (RegExp | 'github' | 'twitter', default: 'github')
— style of mentions; 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

Types

This package is fully typed with TypeScript. It exports the additional type Optionsapi-options.

Compatibility

Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of Node. This means we try to keep the current release line, retext-syntax-mentions@^4, compatible with Node.js 16.

Related

— classify URLs and filepaths as syntax
— check spelling
— check readability
— check possible insensitive, inconsiderate language

Contribute

See contributing.mdcontributing in retextjs/.githubhealth for ways to get started. See support.mdsupport for ways to get help.
This project has a code of conductcoc. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MITlicense © Titus Wormerauthor