Adding spell checking to my 11ty blog

Published February 06, 2024 · 3 min read

I'm not that great with spelling and grammar... For my normal work I use LanguageTool to check my texts. LanguageTool supports both English and Dutch, and that is very important to me. With this blog I'm going to be writing quite a bit, and that needs checking. The simple part is that its only English.

First plan

Very simple: Spin up a LanguageTool server in my CICD pipeline (I use GitLab for now) and check all posts with LanguageTool CLI . Then I could add a job before publishing to run the checks.

The harder part was going to be filtering out the meta-data before the markdown files. That is the place where I store the title, tags and other 11ty data.

Current (simple) implementation

Because of going live with the blog is more important than having a non-live spell-checked blog, I started with a simple package that does basic spell checking (no grammar). Please consider that I'm writing because I want to share interesting things with the world, not to have the most perfect articles on the web.

So I installed node-markdown-spellcheck , ran it and it gave me some suggestions when I misspelled. Biggest thing is that it handles the meta-data.

I ran it in report mode mdspell src/**/*.md -r, that gave me loads of spelling errors consisting mostly about using numbers. Running mdspell src/**/*.md -n -r with the -n flag ignores the numbers. That kept a couple of names like "MQTT" that gave errors. To resolve all issues I run mdspell in interactive mode by removing the -r (report) flag. That give a very nice interface to add the word to the custom dictionary either case sensitive or not. With that everything was done for implementing the report step in the pipelines.

# .gitlab-ci.yaml
spell-check:
  image: node:lts-alpine
  cache:  # Cache modules in between jobs
    key:
      files:
        - package-lock.json
    paths:
      - .npm/
  before_script:
    - npm config set cache .npm --global
    - npm ci --prefer-offline
  script:
    - npx mdspell src/**/*.md -n -r

I've checked that mdspell returns a non-zero exit code when there are error, and it does.

Before publishing I did change all numbers to the written form, just because it the correct way of writing in the Netherlands when the numbers are rather small.

Future plans

Maybe at some point I will change to LanguageTool, just for the spelling. For now this is it and I'll check if it's enough.

Please toot me when you have a comment!


Share

Share on Mastodon - Share on LinkedIn - Share on Facebook