New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

retext-syntax-mentions

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retext-syntax-mentions

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

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
decreased by-11.74%
Maintainers
1
Weekly downloads
 
Created
Source

retext-syntax-mentions

Build Coverage Downloads Size Sponsors Backers Chat

retext plugin to classify @mentions as syntax instead of natural language.

Contents

What is this?

This package is a unified (retext) plugin to classify mentions (as used on for example GitHub) as SourceNode instead of natural language. That node represent “external (ungrammatical) values” instead of natural language, which hides mentions from retext-spell, retext-readability, retext-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 only. In Node.js (version 16+), install with npm:

npm install retext-syntax-mentions

In Deno with esm.sh:

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

In browsers with esm.sh:

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

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
  • options (Options, optional) — configuration
Returns

Transform (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 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.

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

Keywords

FAQs

Package last updated on 07 Sep 2023

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