I'm using aspell to spell check LaTeX documents on Linux. Very often my documents contain samples of code in various programming languages, and I would like aspell to simply skip those lines while spell checking.
Is there anything I can write in my document to turn aspell off on a section of text? Something like:
This line should be spell checked.
% Hey, aspell, don't check the following lines
\begin{lstlisting}
if (xyzzy > foobar) {
doSomethingSilly();
}
\end{lstlisting}
% Hey, aspell, please check the following
This line should be spell checked.
aspell to skip part of document
spellcheck LaTeX documents
LaTeX documents require a little more work.
command
aspell --lang=en_GB --add-tex-command="mySkip op" -c teste.tex
\mySkip[
after { again a \mySkip[
teste.tex
\documentclass{article}
\makeatletter
\def\myComment{\@ifnextchar[{\@with}{\@without}}
\def\@with[#1]#2{Hello #1, have you met #2?}
\def\@without#1{Goodbye #1.}
\makeatother
\mySkip[
if (xyzzy > foobar) {
\mySkip[
doSomethingSilly();
doSomethingOther();
doSomethingExtra();
}
]]
This liine should be spell checked.
Problem after every opening curly brace { in the code you need \mySkip[
\mySkip[
if (abcdef > foobar) {
\mySkip[
doSomethingSilly();
if (test > 100) {
\mySkip[
doSomethingOther();
}
doSomethingExtra();
}
]]
This liine should be spell checked.
With a search and replace you can make the code ready
before replace
after replace
For sgml
it's easier.
Step by step
aspell60-7
teste.html
This line should be spell checked.
<nospell>
if (xyzzy > foobar) {
doSomethingSilly();
}
</nospell>
<script>
if (xyzzy > foobar) {
doSomethingSilly();
}
</script>
This line should be spell checked.
teste.html
aspell60-7
aspell --lang=en_GB --add-filter=sgml --add-sgml-skip=nospell --add-sgml-skip=script -c -S teste.html
after run the command
1) line
.aspell
terminates.Gedit tells file teste.html
was changed.
after new load
liine
is correct.<nospell>
and <script>
are ignored.this also works in windows, but only with aspell6
.