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)

terdon
  • 234,489
  • 66
  • 447
  • 667
Martin Thoma
  • 2,802
  • 5
  • 34
  • 45
  • 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

3 Answers3

6

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.

terdon
  • 234,489
  • 66
  • 447
  • 667
  • 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 06: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
  • > “Haven't really used markdown much but I'd guess you can do the equivalent for it as well.” ␤ Why'd you guess so? I don't really see the link between ispell having latex support and it purportedly also having markdown support. – rien333 Feb 14 '21 at 09:22
  • @rien333 as I say in the answer, I was going for the bonus points. If you read the question, you will see that the bonus points were offered for a spell checker that can deal with LaTeX. – terdon Feb 14 '21 at 13:11
  • My bad, didn't read carefully enough. – rien333 Feb 15 '21 at 16:14
  • @rien333 no worries, I know exactly how that feels :) I'll be deleting our comments soon. – terdon Feb 15 '21 at 16:16