retext plugin to check spelling
npm install retext-spell[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
[retext][] plugin to check spelling.
* What is this?
* When should I use this?
* Install
* Use
* API
* unified().use(retextSpell, options)
* Dictionary
* Options
* Messages
* Types
* Compatibility
* Related
* Contribute
* License
This package is a [unified][] ([retext][]) plugin to check spelling with
[nspell][nspell] and a [dictionary][dictionaries].
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][esm].
In Node.js (version 16+), install with [npm][]:
``sh`
npm install retext-spell
In Deno with [esm.sh][esmsh]:
`js`
import retextSpell from 'https://esm.sh/retext-spell@6'
In browsers with [esm.sh][esmsh]:
`html`
`js
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:
`txtuseles
1:6-1:12 warning Unexpected unknown word , expected for example useless useles retext-spelldocumeant
1:13-1:22 warning Unexpected unknown word , expected for example document documeant retext-spell
⚠ 2 warnings
`
This package exports no identifiers.
The default export is [retextSpell][api-retext-spell].
Check spelling.
###### Parameters
* options ([Options][api-options], required)
— configuration
###### Returns
Transform ([Transformer][unified-transformer]).
Dictionary function (TypeScript type).
###### Type
`ts
type Dictionary = (onload: OnLoad) => undefined | void
type OnLoad = (error: Error | undefined, result?: unknown) => undefined | void
`
Configuration (TypeScript type).
###### Fields
* dictionary ([Dictionary][api-dictionary], required)wooorm/dictionaries
— dictionary function;
result of importing one of the dictionaries in
[][dictionaries]ignore
* (Array, optional)ignoreLiteral
— list of words to ignore
* (boolean, default: true)ignoreDigits
— whether to ignore [literal words][nlcst-is-literal]
* (boolean, default: true)123456
— whether to ignore “words” that contain digits or times such as 2:41pm
or max
* (number, default: 30)normalizeApostrophes
— number of times to suggest;
further misspellings do not get suggestions
* (boolean, default: true)’
— normalize smart apostrophes () as straight (') apostrophes;personal
dictionaries sometimes don’t support smart apostrophes
* (Buffer in UTF-8 or string, optional)
— [personal][nspell-personal] dictionary to use
Each message is emitted as a [VFileMessage][vfile-message] on file, withsource 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][api-dictionary] andOptions
[][api-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 contractions
* retext-diacritics
— check for proper use of diacritics
* retext-indefinite-article
— check if indefinite articles (a, an) are used correctlyretext-redundant-acronyms
* ATM machine
— check for redundant acronyms ()retext-repeated-words
* for for
— check repeated wordsretext-emoji
* retext-syntax-mentions
— classify emoji, gemoji, emoticons
* retext-syntax-urls
— classify @mentions as syntax
*
— classify URLs and filepaths as syntax
See [contributing.md][contributing] in [retextjs/.github][health] for wayssupport.md`][support] for ways to get help.
to get started.
See [
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
[MIT][license] © [Titus Wormer][author]
[build-badge]: https://github.com/retextjs/retext-spell/workflows/main/badge.svg
[build]: https://github.com/retextjs/retext-spell/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/retextjs/retext-spell.svg
[coverage]: https://codecov.io/github/retextjs/retext-spell
[downloads-badge]: https://img.shields.io/npm/dm/retext-spell.svg
[downloads]: https://www.npmjs.com/package/retext-spell
[size-badge]: https://img.shields.io/bundlejs/size/retext-spell
[size]: https://bundlejs.com/?q=retext-spell
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://github.com/retextjs/retext/discussions
[npm]: https://docs.npmjs.com/cli/install
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esmsh]: https://esm.sh
[typescript]: https://www.typescriptlang.org
[health]: https://github.com/retextjs/.github
[contributing]: https://github.com/retextjs/.github/blob/main/contributing.md
[support]: https://github.com/retextjs/.github/blob/main/support.md
[coc]: https://github.com/retextjs/.github/blob/main/code-of-conduct.md
[license]: license
[author]: https://wooorm.com
[dictionaries]: https://github.com/wooorm/dictionaries
[nlcst-is-literal]: https://github.com/syntax-tree/nlcst-is-literal
[nspell]: https://github.com/wooorm/nspell
[nspell-personal]: https://github.com/wooorm/nspell#personal-dictionary-documents
[retext]: https://github.com/retextjs/retext
[unified]: https://github.com/unifiedjs/unified
[unified-transformer]: https://github.com/unifiedjs/unified#transformer
[vfile-message]: https://github.com/vfile/vfile-message
[api-dictionary]: #dictionary
[api-options]: #options
[api-retext-spell]: #unifieduseretextspell-options