Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/larrybahr/website-proofreader
Proofreads HTML for spelling and grammar mistakes
https://github.com/larrybahr/website-proofreader
Last synced: 8 days ago
JSON representation
Proofreads HTML for spelling and grammar mistakes
- Host: GitHub
- URL: https://github.com/larrybahr/website-proofreader
- Owner: larrybahr
- License: mit
- Created: 2019-07-02T21:56:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T03:38:10.000Z (almost 2 years ago)
- Last Synced: 2024-10-31T06:10:43.810Z (about 2 months ago)
- Language: JavaScript
- Size: 466 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# website-proofreader
Proofreads HTML for spelling and grammar mistakes.
I made this because I am a better programmer than a speller. I had many mistakes that would slip through no matter how many times I read over the code. Everyone has heard the saying "if you do not laugh you will cry". It got so bad I did both 😂. This is my ~~atempt~~ attempt to automate the correction process.## Installation
```bash
$ npm install website-proofreader
```
## Features* Spell checking for HTML by NSSpellChecker, Hunspell, or the Windows Spell Check API thanks to [spellchecker](https://www.npmjs.com/package/spellchecker)
* Grammar check via [write-good](https://www.npmjs.com/package/write-good)
* Can check HTML string or URL
* Supports spelling word whitelist## Methods
All examples assume:
```javascript
let wpr = require('website-proofreader');
```### Check
Checks if there are on spelling/grammar errors.
```typescript
interface CheckOptions {
source: string; // HTML or URL to check
dictionary: string[]; // words to ignore in the spelling check
grammarChecks: Object; // {@link https://www.npmjs.com/package/write-good#checks}
}interface CheckResults {
source: string; // Text that was parsed. Any error indexs are valid on this string
grammar: GrammarError[]; // grammar errors
spelling: SpellingError[]; // spelling errors
}interface SpellingError {
word: string; // word with the issue
corrections: string[]; // Possible spelling corrections
indexStart: number; // index the word starts at
indexStop: number; // index the word ends at
}interface GrammarError {
corrections: string[]; // Grammar issue explained
indexStart: number; // index the word starts at
indexStop: number; // index the word ends at
}Check(options: CheckOptions): Promise
```#### Examples
```javascript
wpr.Check({
source: "speling is hard
"
})
.then(function (results)
{
// This is true
results === {
"source": "speling is hard",
"grammar": [],
"spelling": [
{
"word": "speling",
"corrections": [
"spelling",
"spieling",
"spilling",
"spellings",
"spewing"
],
"indexStart": 0,
"indexStop": 7
}
]
}
});wpr.Check({
source: "speling is hard
",
dictionary: ['speling'] // Add a word to the dictionary so it does not error anymore!
})
.then(function (results)
{
// This is true
results === {
"source": "speling is hard",
"grammar": [],
"spelling": []
}
});wpr.Check({
source: 'When writing, an error was made by me.'
})
.then(function (results)
{
// This is true
results === {
"source": "speling is hard",
"grammar": [
{
"corrections": "\"was made\" may be passive voice",
"indexStart": 23,
"indexStop": 31
}
],
"spelling": []
}
});wpr.Check({
source: 'When writing, an error was made by me.',
grammarChecks: {
passive: false // See https://www.npmjs.com/package/write-good#checks for all the checks
}
})
.then(function (results)
{
// This is true
results === {
"source": "speling is hard",
"grammar": [],
"spelling": []
}
});
```## More Examples
For more examples, check out the [test](test) folder in the GitHub repo!
## Tests
To run the test suite, first install the dependencies, then run `npm test`:
```bash
$ npm install
$ npm test
```## Contributing
In lieu of a formal style guide, take care to maintain the existing coding style. Format code with VS Code. Add unit tests for any new or changed functionality. Lint and test your code.
## People
Author and list of all contributors can be found in [package.json](package.json)
## License
See the [LICENSE](https://github.com/larrybahr/website-proofreader/blob/master/LICENSE) file in the repo