Check spelling with retext, based on nspell
.
npm:
npm install retext-spell
var retext = require('retext');
var spell = require('retext-spell');
var dictionary = require('dictionary-en-gb');
var report = require('vfile-reporter');
retext()
.use(spell, dictionary)
.process('Some useles documeant.', function (err, file) {
console.error(report(err || file));
});
Yields:
1:6-1:12 warning `useles` is misspelt; did you mean `useless`? retext-spell retext-spell
1:13-1:22 warning `documeant` is misspelt; did you mean `document`? retext-spell retext-spell
⚠ 2 warnings
retext-spell is async; use
process
, notprocessSync
.
Adds warnings for misspelt words to processed virtual files.
retext().use(spell, dictionary)
retext().use(spell, options)
Optional object.
A dictionary (Function
). Result of requiring one of the
dictionaries in wooorm/dictionaries
.
Personal dictionary (string
or a Buffer
in utf8
, optional).
List of words to ignore (Array.<string>
, default []
).
Whether to ignore literal words (boolean?
, default true
).
Whether to ignore “words” that contain only digits, such as 123456
(boolean?
, default true
).
Deal with apostrophes (boolean?
, default true
). Whether to swap smart
apostrophes (’
) with straight apostrophes ('
) before checking spelling.
Most dictionaries do recognise straight apostrophes (isn't
), but not smart
apostrophes (isn’t
).
Number of unique words to suggest for (number?
, default 30
). By default,
up to thirty words are suggested for. Further misspellings are still warned
about, but without suggestions
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 for
repeated wordsretext-syntax-mentions
— Classify @mentions as syntaxretext-syntax-urls
— Classify URLs and filepaths as syntax
See contribute.md
in retextjs/retext
for ways to get started.
This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.