Adds LaTeX integrity check based on SnuggleTeX #10376
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This ports koppor#646 by @Zylence to here.
This refs #8712.
Background: Snuggletex
Snuggletex is a library from the University of Edinburgh for converting latex to XML, but can be used for latex parsing as well. It is extendible, easy to use and powerful, all whilst containing almost no external dependencies.
In the future, it could become our main latex parser for integrity checks.
What it does do
^
_
$
\command[opt]{arg}{...}
\verb(*)
...\begin{env}[opt]{arg}{...}...\end{env}
What it does not do
&
\#
%
Notes
Some commands may be missing, for example I found
\text{}
to be absent,to check which commands are supported by default, refer here: CorePackageDefinitions.java
Thankfully, enough of the package is exposed to be able to inject new commands, like follows:
engine.getPackages().get(0).addComplexCommandOneArg("text", false, ALL_MODES,LR, StyleDeclarationInterpretation.NORMALSIZE, null, TextFlowContext.ALLOW_INLINE);
Not checked if this is the correct way to represent the text command, but now it parses it correctly.
Translation of SnuggleTeX error messages
We decided NOT to translate ALL SnuggleTeX error messagages. More than 30. See koppor/jabref@
0966619
(#646) for the full list. I opted NOT to translate, because they are not used often (see koppor#646 (comment) for details)Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)