retext-repeated-words

retext plugin to check for for repeated words

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
retext-repeated-words
5.0.09 months ago8 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
retext plugin to check for for repeated words.

Contents

*   [`unified().use(retextRepeatedWords)`](#unifieduseretextrepeatedwords)

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 onlyesm. In Node.js (version 16+), install with npm:
npm install retext-repeated-words

In Deno with esm.shesmsh:
import retextRepeatedWords from 'https://esm.sh/retext-repeated-words@5'

In browsers with esm.shesmsh:
<script type="module">
  import retextRepeatedWords from 'https://esm.sh/retext-repeated-words@5?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 contains:
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))

…then running node example.js yields:
example.txt
1:7-1:12  warning Unexpected repeated `it`, remove one occurrence  it  retext-repeated-words
1:26-1:31 warning Unexpected repeated `to`, remove one occurrence  to  retext-repeated-words
1:51-2:4  warning Unexpected repeated `the`, remove one occurrence the retext-repeated-words

⚠ 3 warnings

API

This package exports no identifiers. The default export is retextRepeatedWordsapi-retext-repeated-words.

unified().use(retextRepeatedWords)

Check for repeated words.
Parameters
There are no parameters.
Returns
Transform (Transformerunified-transformer).
Notes
  • Doesn’t warn for certain 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 VFileMessagevfile-message on file, with source set to 'retext-repeated-words', ruleId to the normalized word, actual to both words, and expected to suggestions.

Types

This package is fully typed with TypeScript. It exports no additional types.

Compatibility

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-repeated-words@^5, compatible with Node.js 16.

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