Draftcheck.jl checks LaTeX documents for common errors using regular expressions. It was inspired by the Python package draftcheck.
We can check a single document like this:
check("myfile.tex", "rules.jl")
By default, it will follow \input
and \include
links if you specify a single file. You can override this by specifying follow_links = false
. If you want to specify an array of files, we can do the following:
check(["myfile1.tex", "myfile2.tex", "myfile3.tex"], "rules.jl")
By default, it will not follow links, but this can be overridden.
It will return true if all checks pass and false otherwise.
We can specify which errors to ignore in a file called allowed.txt
in the directory from which we run the check command. The file must appear identical in format to the output produced by Draftcheck.jl. One workflow is to pipe the output of Draftcheck.jl to allowed.txt
and then remove any lines we want to preserve as errors.
A rule specifies a name, a regular expression, and an error message. Here is an example:
rule("url", r"(?<!\\url{)(\bhttps?://)[^\s.]+\.[-A-Za-z0-9+&@#/%?=~_|!:,.;]+", "Wrap URLs with the \\url command.")
The name is "url". See example.jl
for an example set of rules.
We can ignore rules in a particular line by adding a comment that says "OK" and then the name of the rule. For example:
$1x2$ % OK times
This package is based on some code developed by Cara Ip while an intern at the Stanford Intelligent Systems Laboratory.