retext plugin to check spelling.
- What is this?
- When should I use this?
- Install
- Use
- API
- Messages
- Types
- Compatibility
- Related
- Contribute
- License
This package is a unified (retext) plugin to check spelling with
nspell and a dictionary.
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.
This package is ESM only. In Node.js (version 16+), install with npm:
npm install retext-spellIn 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>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 warningsThis package exports no identifiers.
The default export is retextSpell.
Check spelling.
options(Options, required) — configuration
Transform (Transformer).
Dictionary function (TypeScript type).
type Dictionary = (onload: OnLoad) => undefined | void
type OnLoad = (error: Error | undefined, result?: unknown) => undefined | voidConfiguration (TypeScript type).
dictionary(Dictionary, required) — dictionary function; result of importing one of the dictionaries inwooorm/dictionariesignore(Array<string>, optional) — list of words to ignoreignoreLiteral(boolean, default:true) — whether to ignore literal wordsignoreDigits(boolean, default:true) — whether to ignore “words” that contain digits or times such as123456or2:41pmmax(number, default:30) — number of times to suggest; further misspellings do not get suggestionsnormalizeApostrophes(boolean, default:true) — normalize smart apostrophes (’) as straight (') apostrophes; dictionaries sometimes don’t support smart apostrophespersonal(Bufferin UTF-8 orstring, optional) — personal dictionary to use
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.
This package is fully typed with TypeScript.
It exports the additional types Dictionary and
Options.
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.
retext-contractions— check apostrophe use in contractionsretext-diacritics— check for proper use of diacriticsretext-indefinite-article— check if indefinite articles (a,an) are used correctlyretext-redundant-acronyms— check for redundant acronyms (ATM machine)retext-repeated-words— checkfor forrepeated wordsretext-emoji— classify emoji, gemoji, emoticonsretext-syntax-mentions— classify @mentions as syntaxretext-syntax-urls— classify URLs and filepaths as syntax
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.