Run a spell checker job after the app is built. Requires 'aspell'.
Add this line to your application's Gemfile:
And then execute:
Add the following to middleman's
Spellcheck is run automatically after build, but you can also check individual files and subdirectories:
middleman spellcheck source/about.html middleman spellcheck source/blog/
There are several ways to select what content will be checked.
To spellcheck only some resources using a regex with the URL:
activate :spellcheck, page: "documentation/*" # you can use regexes, too, e.g. /post_[1-9]/
To limit which tags the spell checker will only run through:
activate :spellcheck, tags: :p # pass an array of tags if you have more!
To ignore sections by using css selectors For example, to ignore all sections with a class of
activate :spellcheck, ignore_selector: '.CodeRay'
Or to ignore all tables in a document:
activate :spellcheck, ignore_selector: 'table'
Or to ignore all
activate :spellcheck, ignore_selector: 'p.technical-jargon'
To ignore multiple selectors, seperate them with a comma
activate :spellcheck, ignore_selector: 'p.technical-jargon, .CodeRay'
Middleman-spellcheck automatically ignores
.coffeefile extensions. If there are some additional file type extensions that you would like to skip:
activate :spellcheck, ignored_exts: [".xml", ".png"]
To select a dictionary used by a spellchecker, use lang: option. For example, to use Polish dictionary, use:
activate :spellcheck, lang: "pl"
If you define the
lang metadata in your pages / articles, then spellcheck will use those language.
For warnings only (allow build to pass), use
This is helpful when you want to give yourself a chance to fix mistakes or false hits gradually and
not fail each time you build.
activate :spellcheck, dontfail: 1
You can also disable the automatic spellcheck after build (and only run manual checks from the command line):
activate :spellcheck, run_after_build: false
Advanced users wishing to invoke Middleman-spellcheck backend (Aspell) with a custom command line may find cmdargs: useful. Please note that "-a" is a mandatory flag which one must specify in order for middleman-spellcheck to work. Other flags are up to the user. See Aspell's man page for more details.
activate :spellcheck, cmdargs: "-a -l pl"
For developers interested in extending Middleman-spellcheck and for those who encountered issues, useful might be debug: option, which will turn on extensive amount of debugging.
activate :spellcheck, lang: "en", debug: 1
If there are some words that you would like to be allowed you can pass them to the allow option as an array. **Depricated - Please see the "Fixing spelling mistakes" section for now prefered way to include allowed words
activate :spellcheck, allow: ["Gooby", "pls"]
You can also pass a regex to the
ignore_regex option. Any match will be ignored.
For example to remove words in quotes
activate :spellcheck, lang: "en", ignore_regex: /\s('|")\w*('|")(\s|\.|,)/
Fixing spelling mistakes & false positives
middleman-spellchecker extension is likely to generate large number
of false-positives, e.g.: words which the spellchecker will consider
incorrect (not present in a dictionary), which yet may have a valid meaning
in the article's context. Common problems are acronyms, technical terms and
names. To solve this,
middleman-spellcheck offers two solutions:
spellcheck_allow_filefile, which points to the path with a file containing words considered correct. Author of the website may decide which words are allowed to be used site-wide. Example: if you write a lot about IBM products, this file would have names such as "IBM", "AIX" or "DB/2". Add the words one word per line without quotes.
To set the global file, use the following clause in your
```set :spellcheck_allow_file, "./data/words_allowed.txt"```
spellcheck-allowkeyword in a frontmatter, which will work in the context of this particular article, but not other articles. Example: your blog is about IBM, but 1 article is about AirBnB. You'd put
AirBnBinto your front-matter.
To use 2nd solution, add the following to your frontmatter:
``` title: "Blog about IBM" ... spellcheck-allow: - "AirBnB"``` Another example ``` title: "Some time ago" ... spellcheck-allowed: - GitHub - Linux ```
middleman-spellcheck also comes with a simple CLI for fixing many
problems in your articles. To invoke:
```middleman spellcheck source/blog/2015-11-01-nginx-on-travis-ci.md --fix```
This will pull up simple CLI menu and for each misspelled word, you'll have a following choice
|Key to press||Effect|
|g||Add the word to the
|f||Add the word to this article's front-matter|
|i||Ignore the word for now and deal with it later|
After the run is finished,
middleman-spellchecker will write a fixed file
source/blog/2015-11-01-nginx-on-travis-ci.md.fixed. This is a safe
choice for not creating damage. If you don't want to fiddle with it, the
--inplace switch will make changes dynamically, and the input file will
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request