SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2k stars 362 forks source link

Basic builder: What to do when biber/bibtex is not invoked for some reason #1596

Open Honzaik opened 4 days ago

Honzaik commented 4 days ago

Since this package is not maintained, I am writing this issue note and how to patch it for anyone else who encounters it. It happened to me a few times (seemingly randomly) that bibtex/biber is not invoked and bibliography is not processed causing undefined references. The culprit seems to be https://github.com/SublimeText/LaTeXTools/blob/b27fc391b2e0c7298d7e2be2472f3642e25ed3d2/builders/basicBuilder.py#L35 and the fact that (I guess pdflatex?) outputs a log which includes line breaks after certain amount of characters.

The regex https://github.com/SublimeText/LaTeXTools/blob/b27fc391b2e0c7298d7e2be2472f3642e25ed3d2/builders/basicBuilder.py#L35 tries to find substring in the output of pdflatex that says that citation is undefined

LaTeX Warning: Citation 'abc' on page 1 undefined on input line 4.

But if you citation key is long enough, the log contains the substring

LaTeX Warning: Citation 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' on page 1 un
defined on input line 4.

which is not matched by the regex because there is an extra newline character.

The easiest patch seems to be to remove newlines from the output log before parsing it with the regex. Replace the line https://github.com/SublimeText/LaTeXTools/blob/b27fc391b2e0c7298d7e2be2472f3642e25ed3d2/builders/basicBuilder.py#L151 with

if CITATIONS_REGEX.search(self.out.replace('\n', '')):