14

I would like to run a spellchecker over my articles before I publish them. I think aspell is ok, but it should not try to check code blocks:

asdfasdfa adsfa sdfa text to check adsfasd f

```
a wild code block appeared!
thisHas quiteOften() some strings.that should NOT get changed
```

and also `inlined code` should not get checked

Do command line based spellcheckers exist for Linux that are aware of Markdown and hence ignore code blocks? I need to be able to run this in batch mode for multiple files.

(Bonus points if you know one that really understands LaTeX - no, aspell -t does not completely work)

  • Which editor? I use flyspell-mode with ispell in emacs and I've set it up to ignore LaTeX commands. Works fine. – terdon Jan 15 '14 at 22:52
  • I use vim to do textile for posting to my blog and I believe that is aware of the markup, so they exist. – slm Jan 15 '14 at 23:01
7

I'm going for the bonus points. I use emacs and have flyspell-mode enabled by default for LaTeX documents. It works fine and ignores LaTeX commands.

The relevant lines in my .emacs file are:

;; load flyspell-mode for LaTeX files
(add-hook 'LaTeX-mode-hook 'flyspell-mode) 

;; make flyspell mode ignore latex commands
(setq ispell-extra-args '("--dont-tex-check-comments"))

Haven't really used markdown much but I'd guess you can do the equivalent for it as well.

  • emacs seems not to ignore HTML by default. The first spellcheck-errors I got were from <li>-tags. – Martin Thoma Jan 16 '14 at 6:07
  • 1
    I've asked for a shell based spellchecker, because I would like to check about 400 markdown files. If the spellchecker does not find an error, it should simply quit (without opening a window). I think emacs is not Shell based, is it? – Martin Thoma Jan 16 '14 at 6:12
  • @moose I had not understood that you wanted a commandline utility that an run on multiple files. Emacs might well be able to do this (it does everything else after all) but I don't know how. The flyspell mode simply highlights errors as you type. – terdon Jan 16 '14 at 12:36
  • Thank you for the answer; I think it might be a very good choice for new documents (+1), but for by old documents it doesn't help. I'm sorry for not being clear about the commandline / batch part of the question. – Martin Thoma Jan 16 '14 at 15:57
3
+50

Maybe markdown-spellcheck is the right tool for you. You need to install nodejs/npm.

Test run in interactive mode:

$ cat test.md 
asdfasdfa adsfa sdfa text to check adsfasd f

```
a wildwild code block appppeared!
thisHas quiteOften() some strings.that should NOT get changed
```

and also `inLIned code` should not get checked
$ mdspell test.md 
Spelling - test.md
asdfasdfa adsfa sdfa text to check adsf
?   Ignore
asdfasdfa adsfa sdfa text to check adsfasd f
?   Ignore
asdfasdfa adsfa sdfa text to check adsfasd f
?   Ignore
sdfa adsfa sdfa text to check adsfasd f
?   Ignore
>> 1 file is free from spelling errors

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.