1818* [ Use] ( #use )
1919* [ API] ( #api )
2020 * [ ` unified().use(retextReadability[, options]) ` ] ( #unifieduseretextreadability-options )
21+ * [ ` Options ` ] ( #options )
2122* [ Messages] ( #messages )
2223* [ Types] ( #types )
2324* [ Compatibility] ( #compatibility )
@@ -35,7 +36,7 @@ It applies [Dale—Chall][dale-chall],
3536
3637## When should I use this?
3738
38- You can opt-into this plugin when you’re dealing with content that might be
39+ You can use this plugin when you’re dealing with content that might be
3940difficult to read to some folks, and have authors that can fix that content.
4041
4142> 💡 ** Tip** : I also made an online, editable, demo, similar to this project:
@@ -44,7 +45,7 @@ difficult to read to some folks, and have authors that can fix that content.
4445## Install
4546
4647This package is [ ESM only] [ esm ] .
47- In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0 +), install with [ npm] [ ] :
48+ In Node.js (version 16 +), install with [ npm] [ ] :
4849
4950``` sh
5051npm install retext-readability
@@ -76,15 +77,15 @@ star—Calvera—and H1504+65, the hottest white dwarf yet
7677discovered, with a surface temperature of 200,000 kelvin
7778```
7879
79- …and our module ` example.js ` looks as follows :
80+ …and our module ` example.js ` contains :
8081
8182``` js
82- import {read } from ' to-vfile'
83- import {reporter } from ' vfile-reporter'
84- import {unified } from ' unified'
8583import retextEnglish from ' retext-english'
86- import retextStringify from ' retext-stringify'
8784import retextReadability from ' retext-readability'
85+ import retextStringify from ' retext-stringify'
86+ import {unified } from ' unified'
87+ import {read } from ' to-vfile'
88+ import {reporter } from ' vfile-reporter'
8889
8990const file = await unified ()
9091 .use (retextEnglish)
@@ -95,17 +96,17 @@ const file = await unified()
9596console .error (reporter (file))
9697```
9798
98- …now running ` node example.js ` yields:
99+ …then running ` node example.js ` yields:
99100
100101``` txt
101102example.txt
102- 3:1-5:57 warning Hard to read sentence (confidence: 4/7) retext- readability retext-readability
103+ 3:1-5:57 warning Unexpected hard to read sentence, according to 4 out of 7 algorithms readability retext-readability
103104
104105⚠ 1 warning
105106```
106107
107- The target age is ` 16 ` by default, which you can change .
108- For example, to ` 6 ` :
108+ The default target age is ` 16 ` .
109+ You can pass something else, such as ` 6 ` :
109110
110111``` diff
111112 .use(retextEnglish)
@@ -114,83 +115,71 @@ For example, to `6`:
114115 .use(retextStringify)
115116```
116117
117- …now running ` node example.js ` once moer yields:
118+ …then running ` node example.js ` again yields:
118119
119120``` txt
120121example.txt
121- 1:1-1:23 warning Hard to read sentence (confidence: 4/7) retext- readability retext-readability
122- 3:1-5:57 warning Hard to read sentence (confidence: 7/7) retext-readability retext-readability
122+ 1:1-1:23 warning Unexpected hard to read sentence, according to 4 out of 7 algorithms readability retext-readability
123+ 3:1-5:57 warning Unexpected hard to read sentence, according to all 7 algorithms readability retext-readability
123124
124125⚠ 2 warnings
125126```
126127
127128## API
128129
129130This package exports no identifiers.
130- The default export is ` retextReadability ` .
131+ The default export is [ ` retextReadability ` ] [ api-retext-readability ] .
131132
132133### ` unified().use(retextReadability[, options]) `
133134
134- Detect possibly hard to read sentences.
135+ Check hard to read sentences.
135136
136- ##### ` options `
137+ ###### Parameters
137138
138- Configuration (optional).
139+ * ` options ` ([ ` Options ` ] [ api-options ] , optional)
140+ — configuration
139141
140- ###### ` options.age `
142+ ###### Returns
141143
142- Target age group (` number ` , default: ` 16 ` ).
143- Note that the different algorithms provide varying results, so your milage may
144- vary with people actually that age.
145- :wink :
144+ Transform ([ ` Transformer ` ] [ unified-transformer ] ).
146145
147- ###### ` options.threshold `
146+ ### ` Options `
148147
149- Number of algorithms that need to agree (` number ` , default: ` 4 / 7 ` )
150- By default, 4 out of the 7 algorithms need to agree that a sentence is hard to
151- read for the target age, in which case it’s warned about.
148+ Configuration (TypeScript type).
152149
153- ###### ` options.minWords `
150+ ###### Fields
154151
155- Minimum number of words a sentence should have when warning (` number ` , default:
156- ` 5 ` ).
157- Most algorithms are designed to take a large sample of sentences to detect the
158- body’s reading level.
159- This plugin works on a per-sentence basis and that makes the results quite
160- skewered when a short sentence has a few long words or some unknown ones.
152+ * ` age ` (` number ` , default: ` 16 ` )
153+ — target age group
154+ * ` minWords ` (` number ` , default: ` 5 ` )
155+ — check sentences with at least this number of words;
156+ most algos are made to detect the reading level on an entire text;
157+ this plugin checks each sentence on its own;
158+ for short sentences, one long or complex word can strongly skew the
159+ results
160+ * ` threshold ` (` number ` , default: ` 4 / 7 ` )
161+ — number of algos (out of 7) that need to agree something is hard to read
161162
162163## Messages
163164
164- Each message is emitted as a [ ` VFileMessage ` ] [ message ] on ` file ` , with the
165- following fields:
166-
167- ###### ` message.source `
168-
169- Name of this plugin (` 'retext-readability' ` ).
170-
171- ###### ` message.ruleId `
172-
173- Name of this rule (` 'readability' ` ).
174-
175- ###### ` message.actual `
176-
177- Current not ok sentence (` string ` ).
178-
179- ###### ` message.expected `
180-
181- Empty array as there is no direct fix for ` actual ` (` [] ` ).
165+ Each message is emitted as a [ ` VFileMessage ` ] [ vfile-message ] , with ` source ` set
166+ to ` 'retext-readability' ` , ` ruleId ` to ` 'readability' ` , ` actual ` to the
167+ difficult sentence, and ` expected ` to an empty array.
182168
183169## Types
184170
185171This package is fully typed with [ TypeScript] [ ] .
186- It exports the additional type ` Options ` .
172+ It exports the additional type [ ` Options ` ] [ api-options ] .
187173
188174## Compatibility
189175
190- Projects maintained by the unified collective are compatible with all maintained
176+ Projects maintained by the unified collective are compatible with maintained
191177versions of Node.js.
192- As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
193- Our projects sometimes work with older versions, but this is not guaranteed.
178+
179+ When we cut a new major release, we drop support for unmaintained versions of
180+ Node.
181+ This means we try to keep the current release line, ` retext-readability@^7 ` ,
182+ compatible with Node.js 12.
194183
195184## Related
196185
@@ -229,9 +218,9 @@ abide by its terms.
229218
230219[ downloads ] : https://www.npmjs.com/package/retext-readability
231220
232- [ size-badge ] : https://img.shields.io/bundlephobia/minzip /retext-readability.svg
221+ [ size-badge ] : https://img.shields.io/bundlejs/size /retext-readability
233222
234- [ size ] : https://bundlephobia .com/result?p =retext-readability
223+ [ size ] : https://bundlejs .com/?q =retext-readability
235224
236225[ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
237226
@@ -263,22 +252,28 @@ abide by its terms.
263252
264253[ author ] : https://wooorm.com
265254
266- [ unified ] : https://github.com/unifiedjs/unified
267-
268- [ retext ] : https://github.com/retextjs/retext
269-
270- [ message ] : https://github.com/vfile/vfile-message
271-
272- [ dale-chall ] : https://github.com/words/dale-chall-formula
273-
274255[ automated-readability ] : https://github.com/words/automated-readability
275256
276257[ coleman-liau ] : https://github.com/words/coleman-liau
277258
259+ [ dale-chall ] : https://github.com/words/dale-chall-formula
260+
278261[ flesch ] : https://github.com/words/flesch
279262
280263[ gunning-fog ] : https://github.com/words/gunning-fog
281264
282- [ spache ] : https://github.com/words/spache-formula
265+ [ retext ] : https://github.com/retextjs/retext
283266
284267[ smog ] : https://github.com/words/smog-formula
268+
269+ [ spache ] : https://github.com/words/spache-formula
270+
271+ [ unified ] : https://github.com/unifiedjs/unified
272+
273+ [ unified-transformer ] : https://github.com/unifiedjs/unified#transformer
274+
275+ [ vfile-message ] : https://github.com/vfile/vfile-message
276+
277+ [ api-options ] : #options
278+
279+ [ api-retext-readability ] : #unifieduseretextreadability-options
0 commit comments