Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Makefile
/manual/aspell.html/
/manual/aspell.info
/manual/texinfo.tex
/manual/stamp-vti
/manual/version.texi
/missing
/myspell/Makefile.in
/po/Makefile.in
Expand Down
9 changes: 8 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ dynamic_optfiles =
optfiles = \
modules/filter/email-filter.info\
modules/filter/tex-filter.info\
modules/filter/tex_v1-filter.info\
modules/filter/sgml-filter.info\
modules/filter/markdown-filter.info\
modules/filter/html-filter.info\
Expand All @@ -189,6 +190,7 @@ fltfiles = \
modules/filter/modes/sgml.amf \
modules/filter/modes/markdown.amf \
modules/filter/modes/tex.amf \
modules/filter/modes/tex_v1.amf \
modules/filter/modes/email.amf \
modules/filter/modes/ccpp.amf \
modules/filter/modes/none.amf \
Expand All @@ -208,6 +210,7 @@ static_optfiles += ${optfiles}
libaspell_la_SOURCES +=\
modules/filter/email.cpp\
modules/filter/tex.cpp\
modules/filter/tex_v1.cpp\
modules/filter/sgml.cpp\
modules/filter/markdown.cpp\
modules/filter/context.cpp\
Expand All @@ -221,7 +224,7 @@ filter_ldflags = -module -avoid-version

### Add name of filter library containing your filter. Name always
### must look like lib<filtername>-filter.la see development manual
filter_LTLIBRARIES = email-filter.la tex-filter.la\
filter_LTLIBRARIES = email-filter.la tex-filter.la tex_v1-filter.la \
sgml-filter.la markdown-filter.la context-filter.la\
nroff-filter.la texinfo-filter.la

Expand All @@ -233,6 +236,10 @@ tex_filter_la_SOURCES = modules/filter/tex.cpp
tex_filter_la_LIBADD = libaspell.la
tex_filter_la_LDFLAGS = ${filter_ldflags}

tex_v1_filter_la_SOURCES = modules/filter/tex_v1.cpp
tex_v1_filter_la_LIBADD = libaspell.la
tex_v1_filter_la_LDFLAGS = ${filter_ldflags}

sgml_filter_la_SOURCES = modules/filter/sgml.cpp
sgml_filter_la_LIBADD = libaspell.la
sgml_filter_la_LDFLAGS = ${filter_ldflags}
Expand Down
34 changes: 32 additions & 2 deletions auto/mk-src.in
Original file line number Diff line number Diff line change
Expand Up @@ -1008,15 +1008,45 @@ class: module info list
/
config: config

list methods
method: empty
const
desc => UNIMPLEMENTED. Always returns false (i.e. 0).
/
bool

method: size
const
desc => UNIMPLEMENTED. Always returns 0.
/
unsigned int

method: elements
const
/
module info enumeration

class: dict info list
/
constructor: get aspell dict info list
/
config: config

list methods
method: empty
const
desc => UNIMPLEMENTED. Always returns false (i.e. 0).
/
bool

method: size
const
desc => UNIMPLEMENTED. Always returns 0.
/
unsigned int

method: elements
const
/
dict info enumeration

class: module info enumeration
/
Expand Down
2 changes: 1 addition & 1 deletion config-debug
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ mkdir -p build
cd build
../configure --enable-maintainer-mode \
--disable-shared --disable-pspell-compatibility\
--enable-w-all-error
--enable-w-all-error\
--prefix="`pwd`/../inst" CFLAGS='-g' CXXFLAGS='-g' "$@"
3 changes: 3 additions & 0 deletions manual/aspell.1
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ Check TeX comments.
\fB\-\-add\-tex\-command=\fR\fI<list>\fR, \fB\-\-rem\-tex\-command=\fR\fI<list>\fR
Add or remove a list of TeX commands.
.TP
\fB\-\-add\-tex\-ignore\-env=\fR\fI<list>\fR, \fB\-\-rem\-tex\-ignore\-env=\fR\fI<list>\fR
Add or remove a list of LaTeX environments to skip while spell checking.
.TP
\fB\-\-add\-texinfo\-ignore=\fR\fI<list>\fR, \fB\-\-rem\-texinfo\-ignore=\fR\fI<list>\fR
Add or remove a list of Texinfo commands.
.TP
Expand Down
94 changes: 88 additions & 6 deletions manual/aspell.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1216,14 +1216,22 @@ to 'script' and 'style'.

@subsubsection @TeX{}/LaTeX Filter

The @option{tex} (all lowercase) filter hides @TeX{}/LaTeX commands and
The @option{tex} (all lowercase) filter/mode hides @TeX{}/LaTeX commands and
corresponding parameters that are not readable text in the output from
Aspell. It also skips over @TeX{} comments by default.

Discretionary hyphens and italic corrections are ignored. For example,
@samp{hy\-phen} and @samp{shelf\/ful} are recognized as single words.

@c This filter mode is also available via the
@c @option{latex} alias name.

@table @b

@item tex-check-comments
@i{(boolean)}
Check @TeX{} comments. Defaults to false.

@item tex-command
@i{(list)}
Controls which @TeX{} commands should have certain parameters and/or
Expand All @@ -1232,13 +1240,15 @@ all their parameters and/or options checked. The format for each item
is

@example
<command> <a list of p,P,o and Os>
<command> <a list of 'p', 'P', 'o', 'O' and 'T's>
@end example

The first item is simply the command name. The second item controls
which parameters to skip over. A 'p' skips over a parameter while a
'P' doesn't. Similarly an 'o' will skip over an optional parameter
while an 'O' doesn't. The first letter on the list will apply to the
while an 'O' doesn't. A 'T' will force spell-checking of a parameter
even if the command occurs within a parameter or an environment Aspell
is told to skipped over. The first letter on the list will apply to the
first parameter, the second letter will apply to the second parameter
etc. If there are more parameters than letters Aspell will simply
check them as normal. For example the option
Expand All @@ -1261,6 +1271,25 @@ over the next optional parameter, if it is present, and will skip over
the second parameter --- even if the optional parameter is not present
--- and will check any additional parameters.

@example
add-tex-command foo T
@end example

@noindent
will @emph{check} the first parameter of the @code{foo} command even
if Aspell is currently skipping over an argument or environment. For
example, if Aspell has been told to skip over the @code{bar}
environment (@pxref{Ignoring LaTeX Environments}), then in the text

@example
\begin@{bar@} don't check \foo@{check@} don't check \end@{bar@}
@end example

@noindent
it will nevertheless @emph{check} the argument to @code{foo}. This is
useful to force checking of arguments to text-related commands like
@code{hbox}, @code{text} or @code{intertext} inside math environments.

A @samp{*} at the end of the command is simply ignored. For example
the option

Expand All @@ -1287,15 +1316,57 @@ current defaults.
@c will remove the command foo, if present, from the list of @TeX{}
@c commands.

@item tex-check-comments
@i{(boolean)}
Check @TeX{} comments. Defaults to false.
@anchor{Ignoring LaTeX Environments}
@item tex-ignore-env
@i{(list)}
This controls which @TeX{} environments are skipped over. By default,
Aspell will skip over math formulas inside @code{$...$}, @code{$$...$$},
@code{\(...\)} and @code{\[...\]} and over several common LaTeX and
AMS-LaTeX math environments like @code{equation} and @code{gather}.
For example,

@example
add-tex-ignore-env thebibliography
@end example

@noindent
will tell Aspell to skip over the bibliography as well (which may or
may not be a good idea). As with commands, skipping applies to the
starred form of the environment as well.

@example
rem-tex-ignore-env equation
@end example

@noindent
will make Aspell spell-check the contents of @code{equation} and
@code{equation*} environments. Skipping the contents of @code{$...$},
@code{$$...$$}, @code{\(...\)} and @code{\[...\]} cannot be turned off.

Note that one can force spell-checking of arguments to TeX commands
inside ignored environments with the 'T' parameter to the
@option{add-tex-command} option.

@c @item tex-multi-byte
@c (@i{list}) TeX multi byte letter en|decoding

@end table

As a last resort, when the @option{tex} mode (and not just the filter)
is used, spell checking can be switched off by putting the text
@code{aspell:off} into the file. Similarly, with @code{aspell:on} one
can turn it on again. This can be useful for macro definitions, for
example

@example
% aspell:off
\def\doi#1@{\href@{http://doi.org/#1@}@{doi:#1@}@}
% aspell:on
@end example

@noindent
This feature is implemented via the @ref{Context Filter}.

@c The TeXfilter mode also contains a decoding and an encoding filter for
@c @emph{babel} character codes like the German Umlauts:

Expand Down Expand Up @@ -1404,6 +1475,7 @@ escapes
(@code{\(}) and extended (@code{\[comp1 comp2 @dots{}]}) form.
@end itemize

@anchor{Context Filter}
@subsubsection Context Filter

The @option{context} filter can be used to spell check source codes,
Expand Down Expand Up @@ -3576,6 +3648,13 @@ increase.
@node ChangeLog
@appendix ChangeLog

@heading Changes from 0.60.8.1 to 0.60.9 (???)
@itemize @bullet
@item
Improved @option{tex} filter/mode thanks to work of Matthias. The
original filter/mode is available under the name @option{tex_v1}.
@end itemize

@heading Changes 0.60.8 to 0.60.8.1 (December 19, 2023)
@itemize @bullet
@item
Expand Down Expand Up @@ -5068,6 +5147,9 @@ Wrote the Nroff filter.
Enhanced the SGML filter to also support skipping sgml tags such as
"script" blocks.

@item Matthias Franz
Enhanced the @TeX{}/LaTeX Filter.

@item Kevin B. Hendricks (and Contributors)
Wrote MySpell which is a simple spell checker library that supports
affix compression. Aspell affix compression code is based on his code.
Expand Down
6 changes: 6 additions & 0 deletions modules/filter/context-filter.info
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ TYPE bool
DESCRIPTION swaps visible and invisible text
DEFAULT false
ENDOPTION

OPTION order-num
TYPE string
DEFAULT 0.5
DESCRIPTION between 0 and 1, defaults to 0.5
ENDOPTION
13 changes: 13 additions & 0 deletions modules/filter/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
// interface.
// This was added to Aspell by Christoph Hinterm�ller

#include <errno.h>

#include "settings.h"
#include "gettext.h"

#include "can_have_error.hpp"
#include "config.hpp"
Expand All @@ -22,6 +25,8 @@
#include "string_list.hpp"
#include "vector.hpp"



using namespace acommon;

namespace {
Expand Down Expand Up @@ -77,6 +82,14 @@ namespace {
return true;
}

String order_num_str = config->retrieve("f-context-order-num");
char * endptr;
errno = 0;
order_num_ = strtod(order_num_str.str(), &endptr);
if (errno != 0 || *endptr != '\0' || !(0.0 <= order_num_ && order_num_ <= 1.0))
return make_err(bad_value, "context-order-num", order_num_str,
_("a number between 0 and 1"));

if (config->retrieve_bool("f-context-visible-first")) {
state=visible;
}
Expand Down
7 changes: 7 additions & 0 deletions modules/filter/modes/tex.amf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ MAGIC /0:256:^[ \t]*\\documentclass\[[^\[\]]*\]\{[^\{\}]*\}/tex
DESCRIPTION mode for checking TeX/LaTeX documents

FILTER url

FILTER context
OPTION context-order-num 0.15
OPTION clear-context-delimiters
OPTION add-context-delimiters aspell:off aspell:on
OPTION enable-context-visible-first

FILTER tex
8 changes: 8 additions & 0 deletions modules/filter/modes/tex_v1.amf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MODE tex_v1

ASPELL >=0.60

DESCRIPTION old TeX mode

FILTER url
FILTER tex_v1
Loading