SublimeText / LaTeXTools

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

Autocompletion for BibTeX entries not stripping line breaks in BibTeX fields such as "author" #1559

Open t-jager opened 2 years ago

t-jager commented 2 years ago

In my user LaTeXTools.sublime-settings file I have set

"cite_panel_format": ["{keyword}: {author} - {title} ({year})",""],

and

"cite_autocomplete_format": "{keyword}: {author} - {title} ({year})",

When entering \cite{, then the auto completion menu is triggered. However, only the first author is shown (plus the word "and" that separates multiple authors), and one can only search for the first author's name.

Here is an example:

screenshot

It seems to be an issue with a certain set of BibTeX files that are not parsed correctly. Concretely, with the BibTeX files from here

https://cryptobib.di.ens.fr/

I can reproduce the issue reliably (it yields the above screenshot).

However, when I use BibTeX entries from DBLP, which does not use line breaks in the author field, then it works fine:

DBLP

My best guess for the root of this issue is that the files from https://cryptobib.di.ens.fr/ contain a line break after each "and" between authors, like this:

author = "Yan Huang and Fangguo Zhang and Zhi Hu and Zhijie Liu",

And it seems that LaTeXTools does not strip these line breaks, but stops reading the field after the first line break. In contrast, DBLP BibTeX entries don’t contain line breaks and work fine.

Since BibTeX allows for line breaks in the authors field, it seems that LaTeXTools does not yet parse these fields correctly, as it seems to stop reading the contents of the field at a line break.

t-jager commented 2 years ago

UPDATE:

Indeed, the root of the issue is that LaTeXTools (or maybe the underlying BibTeX parser, which seems to be external?) stops reading an author field at the first line break.

t-jager commented 2 years ago

UPDATE 2:

The issue seems not to appear on Windows. However, I can reliably reproduce it with Sublime Text Build 4126, Stable Channel, with recent installs of LaTeXTools and LaTeXYZ, running on MacOS 12.3.1 Monterey.