Spell checking
check_spelling(filename, pre_release = TRUE, ignore.lines = NULL, known.correct = NULL, known.correct.fixed = NULL, known.wrong = NULL, ignore_spelling_in = NULL, ignore_spelling_in_nth = NULL, bib_files, check_etcs = TRUE, dict_lang = "en_GB", rstudio = FALSE, .report_error)
filename | Path to a LaTeX file to check. |
---|---|
pre_release | Should the document be assumed to be final?
Setting to |
ignore.lines | Integer vector of lines to ignore (due to possibly spurious errors). |
known.correct | Character vector of patterns known to be correct (which will never be raised by this function). |
known.correct.fixed | Character vector of words known to be correct (which will never be raised by this function). |
known.wrong | Character vector of patterns known to be wrong. |
ignore_spelling_in | Command whose first mandatory argument will be ignored. |
ignore_spelling_in_nth | Named list of arguments to ignore; names are the commands to be ignored, values are the |
bib_files | Bibliography files (containing possible clues to misspellings). If supplied, and this function would otherwise throw an error, the |
check_etcs | If |
dict_lang | Passed to |
rstudio | Use the RStudio API? |
.report_error | A function to provide context to any errors. If missing, defaults to |
Called primarily for its side-effect. If the spell check fails, the line at which the first error was detected, with an error message. If the check succeeds, NULL
invisibly.
Extends and enhances hunspell
:
You can add directives
in the document itself. To add a word foobaz
to the dictionary (so its presence does not throw an error), write
% add_to_dictionary: foobaz
on a single line. The advantage of this method is that you can collaborate
on the document without having to keep track of which spelling errors are genuine.
The
directive % ignore_spelling_in: mycmd
which will ignore the spelling of words within the first argument
of \mycmd
.
ignore_spelling_in_file: <file.tex>
will skip the check of <file.tex>
if it is input
or include
in filename
, as well as any files within it. Should appear as it is within input
but with the file extension
Only the root document need be supplied;
any files that are fed via \input
or \include
are checked (recursively).
A historical advantages was that the contents of certain commands were not checked, the spelling of which need not be checked
as they are not printed, viz.
citation and cross-reference commands, and certain optional arguments. Most of these
are now parsed correctly by hunspell
, though some still need to be supplied (including, naturally, user-supplied macros).
Abbreviations and initialisms which are validly introduced will not throw errors. See extract_valid_abbrevations
.
Words preceded by '[sic]' will not throw errors.
The package comes with a suite of correctly_spelled_words
that were not present in hunspell
's
dictionary.
This function should be quite fast, but slower than hunspell::hunspell
(which it invokes).
I aim for less than 500 ms on a real-world report of around 100 pages.
The function is slower when it needs to consult bib_files
, though I recommend adding authors, titles, etc.
to the dictionary
explicitly, or using citeauthor
and friends.
This function is forked from https://github.com/hughparsonage/grattanReporter to parse reports of the Grattan Institute, Melbourne for errors. See https://github.com/HughParsonage/grattex/blob/master/doc/grattexDocumentation.pdf for the full spec. Some checks that package performs have been omitted in this package.
# NOT RUN { url_bib <- paste0("https://raw.githubusercontent.com/HughParsonage/", "grattex/e6cab97145d38890e44e83d122e995e3b8936fc6/", "Report.tex") check_spelling(url_bib) # }