retext-spell

retext plugin to check spelling

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
retext-spell
6606.1.02 months ago7 years agoMinified + gzip package size for retext-spell in KB

Readme

retext-spell
!Buildbuild-badgebuild !Coveragecoverage-badgecoverage !Downloadsdownloads-badgedownloads !Sizesize-badgesize !Sponsorssponsors-badgecollective !Backersbackers-badgecollective !Chatchat-badgechat
retext plugin to check spelling.

Contents

*   [`unified().use(retextSpell, options)`](#unifieduseretextspell-options)
*   [`Dictionary`](#dictionary)
*   [`Options`](#options)

What is this?

This package is a unified
(retext) plugin to check spelling with nspellnspell and a dictionarydictionaries.

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 onlyesm. In Node.js (version 16+), install with npm:
npm install retext-spell

In Deno with esm.shesmsh:
import retextSpell from 'https://esm.sh/retext-spell@6'

In browsers with esm.shesmsh:
<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 retextSpellapi-retext-spell.

unified().use(retextSpell, options)

Check spelling.
Parameters
— configuration
Returns
Transform (Transformerunified-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 function;
result of importing one of the dictionaries in
[`wooorm/dictionaries`][dictionaries]
  • ignore (Array<string>, optional)
— list of words to ignore
  • ignoreLiteral (boolean, default: true)
— whether to ignore [literal words][nlcst-is-literal]
  • 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][nspell-personal] dictionary to use

Messages

Each message is emitted as a VFileMessagevfile-message 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 Dictionaryapi-dictionary and 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-spell@^6, compatible with Node.js 16.

Related

— check apostrophe use in contractions
— check for proper use of diacritics
— check if indefinite articles (`a`, `an`) are used correctly
— check for redundant acronyms (`ATM machine`)
— check `for for` repeated words
— classify emoji, gemoji, emoticons
— classify [**@mentions**](https://github.com/blog/821) as syntax
— classify URLs and filepaths as syntax

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