Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds LaTeX integrity check based on SnuggleTeX #10376

Merged
merged 3 commits into from
Sep 13, 2023
Merged

Conversation

koppor
Copy link
Member

@koppor koppor commented Sep 12, 2023

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

  • ^
  • _
  • $
  • commands: \command[opt]{arg}{...}
  • verbs: \verb(*)...
  • environments: \begin{env}[opt]{arg}{...}...\end{env}
  • user-defined commands

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

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@koppor koppor mentioned this pull request Sep 12, 2023
6 tasks
@github-actions
Copy link
Contributor

github-actions bot commented Sep 12, 2023

The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build.

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Sep 12, 2023
Siedlerchr
Siedlerchr previously approved these changes Sep 12, 2023
@Siedlerchr
Copy link
Member

can you show a screenshot?

@koppor
Copy link
Member Author

koppor commented Sep 12, 2023

Screenshot:

image

BibTeX:

@Article{,
  journal = {$\left($},
  title   = {$x_i_j$},
}

@koppor
Copy link
Member Author

koppor commented Sep 13, 2023

Merge commit to preserve correct main author ship.

At squash-merge, GitHub would use my username and put @Zylence as "Co-Authored-By".

@koppor koppor merged commit 183375e into main Sep 13, 2023
14 of 16 checks passed
@koppor koppor deleted the add-latex-integrity-check branch September 13, 2023 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants