retext-equality
retext plugin to check for possible insensitive, inconsiderate language.
Contents
- What is this?
- When should I use this?
- Install
- Use
- API
- Messages
- Types
- Compatibility
- Related
- Contributing
- License
What is this?
This package is a unified (retext) plugin to check for certain words that could be considered insensitive, or otherwise inconsiderate, in certain contexts.
When should I use this?
You can opt-into this plugin when you’re dealing with your own text and want to check for potential mistakes.
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-equality
In Deno with esm.sh
:
import retextEquality from 'https://esm.sh/retext-equality@6'
In browsers with esm.sh
:
<script type="module">
import retextEquality from 'https://esm.sh/retext-equality@6?bundle'
</script>
Use
Say our document example.txt
contains:
He’s pretty set on beating your butt for sheriff.
…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 retextEquality from 'retext-equality'
import retextStringify from 'retext-stringify'
const file = await unified()
.use(retextEnglish)
.use(retextEquality)
.use(retextStringify)
.process(await read('example.txt'))
console.error(reporter(file))
…now running node example.js
yields:
example.txt
1:1-1:5 warning `He’s` may be insensitive, use `They`, `It` instead he-she retext-equality
âš 1 warning
API
This package exports no identifiers.
The default export is retextEquality
.
unified().use(retextEquality[, options])
Check for possible insensitive, inconsiderate language.
options
Configuration (optional).
options.ignore
List of phrases not to warn about (Array<string>
).
options.noBinary
Do not allow binary references (boolean
, default: false
).
By default he
is warned about unless it’s followed by something like or she
or and she
.
When noBinary
is true
, both cases will be warned about.
Messages
See rules.md
for a list of rules and how rules work.
Each message is emitted as a VFileMessage
on file
, with the
following fields:
message.source
Name of this plugin ('retext-equality'
).
message.ruleId
See id
in rules.md
.
message.actual
Current not ok phrase (string
).
message.expected
Suggest ok phrase (Array<string>
).
message.note
Extra info, when available (string?
).
Types
This package is fully typed with TypeScript.
It exports the additional type Options
.
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
alex
— Catch insensitive, inconsiderate writingretext-passive
— Check passive voiceretext-profanities
— Check for profane and vulgar wordingretext-simplify
— Check phrases for simpler alternatives
Contributing
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.
To create new patterns, add them in the YAML files in the data/
directory, and run npm install
and then npm test
to build everything.
Please see the current patterns for inspiration.
New English rules will automatically be added to rules.md
.
When you are happy with the new rule, add a test for it in test.js
,
and open a pull request.
License
MIT © Titus Wormer