https://github.com/rcasto/readability-component
A web component that calculates the readability and average reading time of text it encapsulates
https://github.com/rcasto/readability-component
readability readability-level web-component
Last synced: 4 months ago
JSON representation
A web component that calculates the readability and average reading time of text it encapsulates
- Host: GitHub
- URL: https://github.com/rcasto/readability-component
- Owner: rcasto
- Created: 2019-12-22T23:38:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T02:22:28.000Z (over 3 years ago)
- Last Synced: 2025-02-26T06:13:32.466Z (about 1 year ago)
- Topics: readability, readability-level, web-component
- Language: JavaScript
- Homepage: https://rcasto.github.io/readability-component/
- Size: 3.39 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Readability Web Component
A web component that can be used to wrap around your text content and determine its readability level, as well as the average time it would take to read.
To determine the readability level the [Flesch Kincaid readability test](https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests) is used.
To determine the average time to read the content, an average reading speed of 180 words per minute is used.
**Note:** A heuristic is utilized to determine the number of syllables in a word, so the readability level may not be exactly what it would be if you were to manually calculate it, but it should not be terribly far off.
[Try it out! (codepen)](https://codepen.io/rcasto/pen/gOaxjKM)
## Usage
### Via script tag
```html
Readability Web Component
read-ability {
/* Allow customization of some of the Web components styling via
CSS properties */
--readability-margin: 0 0 16px 0;
--readability-font-size: 0.8em;
--readability-font-weight: lighter;
--readability-opacity: 0.8;
--readability-spacer-margin: 0 6px;
--readability-justify-content: center;
}
```
### Via module bundler
1. Install package via package manager of your choice.
```
npm install readability-component
```
2. `import 'readability-component'` as part of your app module, it should then be included as part of your bundle.
```javascript
import 'readability-component';
// Rest of your code...
```
3. You can now use `` in your app views!
## Resources
- https://www.howmanysyllables.com/howtocountsyllables
- https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests#Flesch%E2%80%93Kincaid_grade_level
- https://en.wikipedia.org/wiki/Words_per_minute#Reading_and_comprehension