retext-repeated-words
retext plugin to check for repeated words.for
Contents
What is this?
This package is a unified (retext) plugin to check for repeated words. For example, like like
this.
When should I use this?
You can opt-into this plugin when you’re dealing with content that might contain grammar mistakes, and have authors that can fix that content.
Install
This package is ESM only. In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with npm:
npm install retext-repeated-words
In Deno with esm.sh
:
import retextRepeatedWords from 'https://esm.sh/retext-repeated-words@4'
In browsers with esm.sh
:
<script type="module">
import retextRepeatedWords from 'https://esm.sh/retext-repeated-words@4?bundle'
</script>
Use
Say our document example.txt
contains:
Well, it it doesn’t have to to be. Like a fish in the
the sea.
…and our module example.js
looks as follows:
import {read} 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 = await unified()
.use(retextEnglish)
.use(retextRepeatedWords)
.use(retextStringify)
.process(await read('example.txt'))
console.error(reporter(file))
…now running node example.js
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…
)
There are no options.
Messages
Each message is emitted as a VFileMessage
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']
).
Types
This package is fully typed with TypeScript. It exports no additional types.
Compatibility
Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+. Our projects sometimes work with older versions, but this is not guaranteed.
Related
retext-indefinite-article
— check if indefinite articles are used correctlyretext-redundant-acronyms
— check for redundant acronyms
Contribute
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.