spelling post progress

This commit is contained in:
David Eisinger
2024-11-20 16:19:47 -05:00
parent 48230935e7
commit 4087839320

View File

@@ -8,30 +8,130 @@ tags:
Bla bla bla
[5]: https://cspell.org/
<!--more-->
### 1. Install CSpell
Assuming a modern version of Node.js (>= 18), you can use [npx][1] to download and run CSpell in a single command:
```sh
npx cspell content/**/*.md
```
You'll see a ton of spelling errors -- ignore them for now.
[1]: https://docs.npmjs.com/cli/v10/commands/npx
### 2. Add config file
### 3. Ignore frontmatter
Next, let's create a basic config file. In the root of your site, put the following in `.cspell.json`:
### 4. Ignore proper nouns
```json
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"dictionaries": [
"english"
]
}
```
### 5. Fix spelling
### 3. Add additional languages
### 6. Create custom dictionary
My site (especially the stuff in [/elsewhere][2] that I've mirrored from my company's website) has code snippets that the English dictionary doesn't recognize. Fortunately, CSpell ships with a bunch of [additional dictionaries][3]. Adding `"ruby"`, `"golang"`, and `"java"` to the `"dictionaries"` array makes a bunch of misspellings go away.
### 7. Add to build pipeline
[2]: /elsewhere
[3]: https://github.com/streetsidesoftware/cspell-dicts/tree/main/dictionaries
### 4. Ignore front matter
```json
"patterns": [
{
"name": "frontmatter",
"pattern": "/^(-{3}|[+]{3})$(\\s|\\S)*?^\\1$/gm"
}
],
"languageSettings": [
{
"languageId": "markdown",
"ignoreRegExpList": [
"frontmatter",
]
}
]
```
[6]: https://gohugo.io/content-management/front-matter/
[7]: https://github.com/streetsidesoftware/cspell/discussions/3456#discussioncomment-3438647
### 5. Ignore proper nouns
```json
{
"name": "proper_nouns",
"pattern": "/[\\W_][A-Z][\\S]+/g"
}
```
```json
"languageSettings": [
{
"languageId": "markdown",
"ignoreRegExpList": [
"frontmatter",
"proper_nouns"
]
}
]
```
### 6. Fix spelling
### 7. Create custom dictionary
```sh
npx cspell --words-only --unique content/**/*.md >> .dictionary
```
```json
"dictionaryDefinitions": [
{
"name": "exceptions",
"path": ".dictionary",
"addWords": true
}
],
```
```json
"dictionaries": [
"english",
"ruby",
"golang",
"exceptions"
]
```
```sh
npx cspell --words-only --unique content/**/*.md >> .dictionary
sort -o .dictionary .dictionary
```
### 8. Add to build pipeline
[8]: https://git.sr.ht/~dce/davideisinger.com/tree/main/item/.build.yml#L23-24
---
[Here's the final `.cspell.json` config file.][1]
[Here's the final `.cspell.json` config file.][4]
[1]: https://git.sr.ht/~dce/davideisinger.com/tree/main/item/.cspell.json
[2]: https://cspell.org/
[3]: https://github.com/streetsidesoftware/cspell/discussions/3456#discussioncomment-3438647
[4]: https://git.sr.ht/~dce/davideisinger.com/tree/main/item/.build.yml#L23-24
[4]: https://git.sr.ht/~dce/davideisinger.com/tree/main/item/.cspell.json
---
```json
{
@@ -71,15 +171,3 @@ Bla bla bla
]
}
```
```sh
npx cspell content/**/*.md
```
```sh
npx cspell --words-only --unique content/**/*.md >> .dictionary
```
```sh
sort -o .dictionary .dictionary
```