til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Use spellcheck

I am the current maintainer of Robert Jordan’s (@rojopolis) GitHub action: spellcheck.

This is a pretty basic GitHub action based on the Python program: PySpelling, which is a a Python implementation on top of aspell and hunspell.

The manual should get you going if you want to implement checking of the spelling in your GitHub repository.

So here follows some more tips I stuff I have learned working with spellcheck and it’s dependencies.

Create a custom dictionary fast

Since you can get PySpelling to ignore words, which would be reported as spelling errors, since the are not present in the available dictionary, if is often interesting to be able to create your own custom list of words to ignore.

$ pyspelling --config .spellcheck.yaml \
| grep -v -e '^Misspelled words' \
| grep -v -e '\-\-\-\-' \
| grep -v -e '^<htmlcontent>' \
| grep -v -e '^[[:space:]]*$' \
| grep -v -e '^!!!Spelling check failed!!!' \
| sort -u > .wordlist.txt

Lets walk through the invocation.

grep -v -e '^Misspelled words'

Suppresses indication of misspelled words.

grep -v -e '^<htmlcontent>'

Suppresses some information on the DOM whereabouts of the word.

grep -v -e '\-\-\-\-'

Suppresses a separator, used between the above indicator and the actual works

grep -v -e '^[[:space:]]*$'

Suppresses empty lines, also used as a separator.

grep -v -e '^!!!Spelling check failed!!!'

Suppresses the message emitted when a spelling check fails.

Do note that if you use PySpelling’s verbosity flags, more output will be emitted and additional suppressions will have to be put in place.

But you get the picture from the original example, which should be easy to extend.

Resources and References