retext-repeated-words

retext plugin to check for for repeated words

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
retext-repeated-words
1004.2.0a year ago6 years agoMinified + gzip package size for retext-repeated-words in KB

Readme

retext-repeated-words
!Buildbuild-badgebuild !Coveragecoverage-badgecoverage !Downloadsdownloads-badgedownloads !Sizesize-badgesize !Sponsorssponsors-badgecollective !Backersbackers-badgecollective !Chatchat-badgechat
retextretext plugin to check for for repeated words.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.
npm install retext-repeated-words
## Use

Say we have the following file, `example.txt`:

```txt
Well, it it doesn’t have to to be. Like a fish in the
the sea.

…and our script, example.js, looks like this:
import {readSync} from 'to-vfile'
import {reporter} from 'vfile-reporter'
import {unified} from 'unified'
import retextEnglish from 'retext-english'
import retextStringify from 'retext-stringify'
import retextRepeatedWords from 'retext-repeated-words'

const file = readSync('example.txt')

unified()
  .use(retextEnglish)
  .use(retextRepeatedWords)
  .use(retextStringify)
  .process(file)
  .then((file) => {
    console.error(reporter(file))
  })

Now, running node example yields:
example.txt
   1:7-1:12  warning  Expected `it` once, not twice   it   retext-repeated-words
  1:26-1:31  warning  Expected `to` once, not twice   to   retext-repeated-words
   1:51-2:4  warning  Expected `the` once, not twice  the  retext-repeated-words

⚠ 3 warnings

API

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

unified().use(retextRepeatedWords)

Check for repeated words.
  • Doesn’t warn for some words which do occur twice (`the best exhibition
they had had since`)
  • Doesn’t warn for initialisms (D. D. will pop up with…)
  • Doesn’t warn for capitalised words (Duran Duran…)

Messages

Each message is emitted as a VFileMessagemessage on file, with the following fields:
message.source
Name of this plugin ('retext-repeated-words').
message.ruleId
Repeated word (normalized) (string, such as the).
message.actual
Current not ok phrase (string).
message.expected
List of suggestions (Array.<string>, such as ['the']).

Related

— Check if indefinite articles are used correctly
— Check for redundant acronyms

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