unified

Project: retextjs/retext-redundant-acronyms

Package: retext-redundant-acronyms@4.3.0

  1. Dependents: 0
  2. retext plugin to check for redundant acronyms (ATM machine)
  1. unified 179
  2. plugin 138
  3. retext 42
  4. retext-plugin 26

retext-redundant-acronyms

Build Coverage Downloads Size Sponsors Backers Chat

retext plugin to check for redundant acronyms (such as ATM machine to ATM).

Contents

What is this?

This package is a unified (retext) plugin to check for redundant acronyms (such as ATM machine to ATM).

🙂 Fun fact: this is called RAS syndrome (redundant acronym syndrome syndrome).

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-redundant-acronyms

In Deno with esm.sh:

import retextRedundantAcronyms from 'https://esm.sh/retext-redundant-acronyms@4'

In browsers with esm.sh:

<script type="module">
  import retextRedundantAcronyms from 'https://esm.sh/retext-redundant-acronyms@4?bundle'
</script>

Use

Say our document example.txt contains:

Where can I find an ATM machine?

…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 retextRedundantAcronyms from 'retext-redundant-acronyms'
import retextStringify from 'retext-stringify'

const file = await unified()
  .use(retextEnglish)
  .use(retextRedundantAcronyms)
  .use(retextStringify)
  .process(await read('example.txt'))

console.error(reporter(file))

…now running node example.js yields:

example.txt
  1:21-1:32  warning  Expected `ATM` instead of `ATM machine`  atm  retext-redundant-acronyms

⚠ 1 warning

API

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

unified().use(retextRedundantAcronyms)

Check for redundant acronyms (such as ATM machine to ATM).

Messages

Each message is emitted as a VFileMessage on file, with the following fields:

message.source

Name of this plugin ('retext-redundant-acronyms').

message.ruleId

Lower case matched abbreviation (string, such as 'atm')

message.actual

Current not ok phrase (string, such as 'ATM machines').

message.expected

List of suggestions (Array<string>, such as ['ATMs']).

Types

This package is fully typed with TypeScript. It does not export 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.

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.

License

MIT © Titus Wormer