Hi, I’m Erika Rowland (a.k.a. erikareads). Hi, I’m Erika. I’m an Ops-shaped Software Engineer, Toolmaker, and Resilience Engineering fan. I like Elixir and Gleam, Reading, and Design. She/Her. Constellation Webring Published on

Tools I Use: codespell

codespell is a command line spellcheck tool that is code-aware. Codespell allows me to spellcheck my software projects without getting stuck on all the jargon that software projects use.

Usage and Tips

I often use codespell to spellcheck the markup for this blog. It’s nice to have a tool that doesn’t get stuck on the code blocks I use in my articles.

It does occasionally get caught on rarer words or words that have more common English spellings for example, running it on my site’s markup folder gives me this:Unconfigured. My configuration later in the article fixes this.

content/notes/crate-reqwest.dj:1: Crate ==> Create
content/notes/crate-reqwest.dj:4: Crate ==> Create
content/notes/crate-surf.dj:1: Crate ==> Create
content/notes/crate-surf.dj:4: Crate ==> Create
content/notes/bookmarks/2023-07-20.dj:149: simpy ==> simply

Both “Crate” and “simpy” are correct, the former is a legitimate English word, and the latter is a part of a URL.As confirmed by Wikitionary: crate. Which specifically has a definition for the Rust usage.This catch on “crate” is because of the default dictionary option, which is set to clear,rare. This behavior can be modified with the --builtin clear option to only show errors on unambiguous errors.

As such, while codespell has a --write-changes flag, I would caution against its use in a non-interactive mode.

Interactive

codespell does allow for interactive updates with a combination of flags:

codespell <optional_folder> --interactive 1 --write-changes

Ignore words

Another option is to use the --ignore-words-list option, which takes a comma separated list of words to ignore:

codespell <optional_folder> --ignore-words-list crate,simpy

If you have enough words to make passing them as a comma separated list unwieldy, then you can use --ignore-words to pass a file with each word on its own line.

Config

codespell will look for a .codespellrc file in the local directory for configuration.Despite mentioning toml in the README, the configuration format is not toml. Which took me a bit to figure out. toml only seems to apply if you configure it with pyproject.toml.The default configuration format seems to be closer to an ini format.

I’ve set my config for this site like this:

[codespell]
builtin = clear
ignore-words-list = simpy

Takeaways

codespell is a neat little tool for spellchecking in a code heavy environment. I use it regularly to spellcheck these articles. I use few of its additional features or options, just a simple, effective command-line spellchecking tool.


Constellation Webring