Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

retext-spell

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retext-spell

retext plugin to check spelling

  • 6.1.0
  • latest
  • Source
  • npm
  • Socket score

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

retext-spell

Build Coverage Downloads Size Sponsors Backers Chat

retext plugin to check spelling.

Contents

What is this?

This package is a unified (retext) plugin to check spelling with nspell and a dictionary.

When should I use this?

You can opt-into this plugin when you’re dealing with content that might contain spelling mistakes, and have authors that can fix that content.

Install

This package is ESM only. In Node.js (version 16+), install with npm:

npm install retext-spell

In Deno with esm.sh:

import retextSpell from 'https://esm.sh/retext-spell@6'

In browsers with esm.sh:

<script type="module">
  import retextSpell from 'https://esm.sh/retext-spell@6?bundle'
</script>

Use

import dictionaryEn from 'dictionary-en'
import {retext} from 'retext'
import retextSpell from 'retext-spell'
import {reporter} from 'vfile-reporter'

const file = await retext()
  .use(retextSpell, {dictionary: dictionaryEn})
  .process('Some useles documeant.')

console.error(reporter(file))

Yields:

1:6-1:12  warning Unexpected unknown word `useles`, expected for example `useless`     useles    retext-spell
1:13-1:22 warning Unexpected unknown word `documeant`, expected for example `document` documeant retext-spell

⚠ 2 warnings

API

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

unified().use(retextSpell, options)

Check spelling.

Parameters
  • options (Options, required) — configuration
Returns

Transform (Transformer).

Dictionary

Dictionary function (TypeScript type).

Type
type Dictionary = (onload: OnLoad) => undefined | void

type OnLoad = (error: Error | undefined, result?: unknown) => undefined | void

Options

Configuration (TypeScript type).

Fields
  • dictionary (Dictionary, required) — dictionary function; result of importing one of the dictionaries in wooorm/dictionaries
  • ignore (Array<string>, optional) — list of words to ignore
  • ignoreLiteral (boolean, default: true) — whether to ignore literal words
  • ignoreDigits (boolean, default: true) — whether to ignore “words” that contain digits or times such as 123456 or 2:41pm
  • max (number, default: 30) — number of times to suggest; further misspellings do not get suggestions
  • normalizeApostrophes (boolean, default: true) — normalize smart apostrophes () as straight (') apostrophes; dictionaries sometimes don’t support smart apostrophes
  • personal (Buffer in UTF-8 or string, optional) — personal dictionary to use

Messages

Each message is emitted as a VFileMessage on file, with source set to 'retext-spell', ruleId to the normalized unknown word, actual to the unknown word, and expected to an array with suggestions.

Types

This package is fully typed with TypeScript. It exports the additional types Dictionary and 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-spell@^6, 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 05 Feb 2024

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