emacs-citar / citar

Emacs package to quickly find and act on bibliographic references, and edit org, markdown, and latex academic documents.
GNU General Public License v3.0
512 stars 55 forks source link

Failing to parse valid BibTeX entries #682

Closed ramos closed 2 years ago

ramos commented 2 years ago

Describe the bug Entries formatted with double braces fail to display correctly

To Reproduce Use a BibTeX file with an entry like:

@Article{Luscher:1992an,
  Title =    {{The Schr{\"o}dinger Functional: a renormalizable
                  probe for non-abelian gauge theories}},
  Author =   {L{\"u}scher, Martin and Narayanan, Rajamani and
                  Weisz, Peter and Wolff, Ulli},
  Journal =  {Nucl.Phys.},
  Year =     1992,
  Pages =    {168--228},
  Volume =   {B384},
  Archiveprefix ={arXiv},
  Doi =      {10.1016/0550-3213(92)90466-O},
  Eprint =   {hep-lat/9207009},
  Primaryclass = {hep-lat},
  Reportnumber = {DESY-92-025, CERN-TH-6410-92},
  Slaccitation = {%%CITATION = HEP-LAT/9207009;%%}
}

citar fails to properly show the entry (i.e. title is missing).

Expected behavior Entry should be correctly displayed.

Emacs version: 28.0.5

Additional context Note that certain sited like inspires used to produce the BibTeX entries in this format in the past. Many legacy large BibTeX files fail to work with emacs-citar

bdarcus commented 2 years ago

We don't actually do the parsing; we use parsebib for that.

You might test a bit with parsebib-parse, and if you confirm, report there with details?

aikrahguzar commented 2 years ago

Are you using the latest citar version? I remember there was a bug where citar treated the bibtex keys as case sensitive and that can cause this but it was fixed a while back.

ramos commented 2 years ago

You might test a bit with parsebib-parse, and if you confirm, report there with details?

Hi,

It seems that citaris looking for title, year, ... and not Title, Year, ... This is weird, because tag's names are not case sensitive in BibTeX.

A more detailed example. A file with a single entry:

@Article{Luscher:2014kea,
  Title                    = {{Step scaling and the Yang-Mills gradient flow}},
  Author                   = {L\"uscher, Martin},
  Journal                  = {JHEP},
  Year                     = {2014},
  Pages                    = {105},
  Volume                   = {1406},

  Archiveprefix            = {arXiv},
  Doi                      = {10.1007/JHEP06(2014)105},
  Eprint                   = {1404.5930},
  Primaryclass             = {hep-lat},
  Reportnumber             = {CERN-PH-TH-2014-065},
  Slaccitation             = {%%CITATION = ARXIV:1404.5930;%%}
}

is parsed correctly by parsebib-parse: (parsebib-parse "o.bib")results in:

#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("Luscher:2014kea" (("Slaccitation" . "%%CITATION = ARXIV:1404.5930;%%") ("Reportnumber" . "CERN-PH-TH-2014-065") ("Primaryclass" . "hep-lat") ("Eprint" . "1404.5930") ("Doi" . "10.1007/JHEP06(2014)105") ("Archiveprefix" . "arXiv") ("Volume" . "1406") ("Pages" . "105") ("Year" . "2014") ("Journal" . "JHEP") ("Author" . "Lüscher, Martin") ("Title" . "Step scaling and the Yang-Mills gradient flow") ...)))

On the other hand citar-insert-citation shows the entry Luscher:2014kea, but with all the fields missing: o

If I change the entry to:

@article{Luscher:2014kea,
    author = {L\"uscher, Martin},
    title = "{Step scaling and the Yang-Mills gradient flow}",
    eprint = "1404.5930",
    archivePrefix = "arXiv",
    primaryClass = "hep-lat",
    reportNumber = "CERN-PH-TH-2014-065",
    doi = "10.1007/JHEP06(2014)105",
    journal = "JHEP",
    volume = "06",
    pages = "105",
    year = "2014"
}

(i.e. note, keys are now lowercase), parsebib-parseapparently returns the same:

#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("Luscher:2014kea" (("year" . "2014") ("pages" . "105") ("volume" . "06") ("journal" . "JHEP") ("doi" . "10.1007/JHEP06(2014)105") ("reportNumber" . "CERN-PH-TH-2014-065") ("primaryClass" . "hep-lat") ("archivePrefix" . "arXiv") ("eprint" . "1404.5930") ("title" . "Step scaling and the Yang-Mills gradient flow") ("author" . "Lüscher, Martin") ("=type=" . "article") ...)))

and now citar shows the entry correctly: oo

The difference between both BibTeX formats is how the entry is displayed by https://inspirehep.net/ now, and a few years back. This is the main bib database in high energy physics, so I guess that it should affect other users.

Many thanks for a great package!

bdarcus commented 2 years ago

And did you confirm, per @aikrahguzar, that you're on latest citar version?

aikrahguzar commented 2 years ago

The difference between both BibTeX formats is how the entry is displayed by https://inspirehep.net/ now, and a few years back. This is the main bib database in high energy physics, so I guess that it should affect other users.

I use INSPIRE for all my bibliographic needs and looking at an old file was how I discovered the bug I mentioned earlier and it is fixed now. You are on an old version of citar is my guess.

ramos commented 2 years ago

And did you confirm, per @aikrahguzar, that you're on latest citar version?

I am sorry. I updated with straight-pull-package and re-loaded the packae. Thugh that this was enough, but now I have killed/restarted the server and everything is working.

Sorry again, and many thanks

ramos commented 2 years ago

The difference between both BibTeX formats is how the entry is displayed by https://inspirehep.net/ now, and a few years back. This is the main bib database in high energy physics, so I guess that it should affect other users.

I use INSPIRE for all my bibliographic needs and looking at an old file was how I discovered the bug I mentioned earlier and it is fixed now. You are on an old version of citar is my guess.

Sorry, my mistake

bdarcus commented 2 years ago

Glad it's working fine now :-)