ORCID / bibtexParseJs

A JavaScript library that parses BibTeX parser.
MIT License
107 stars 39 forks source link

Parsing quote (") and percentage (%) characters #3

Closed DerekDomino closed 10 years ago

DerekDomino commented 10 years ago

Hello,

I'm using bibtexParseJs for reading references from InspireHEP (a comprehensive database of papers in High Energy Physics).

InspireHEP BibTeX output is as follows (note the title and SLACcitation fields):

@article{Chen:2014oha,
      author         = "Chen, Chien-Yi and Davoudiasl, Hooman and Kim, Doojin",
      title          = "{Warped Graviton "Z + Missing Energy" Signal at Hadron
                        Colliders}",
      journal        = "Phys.Rev.",
      volume         = "D89",
      pages          = "096007",
      doi            = "10.1103/PhysRevD.89.096007",
      year           = "2014",
      eprint         = "1403.3399",
      archivePrefix  = "arXiv",
      primaryClass   = "hep-ph",
      SLACcitation   = "%%CITATION = ARXIV:1403.3399;%%",
}

Title may contain quote characters (as well as latex formatting), I think it is valid since a couple of braces embeds those characters. Moreover the SLACcitation field use the % symbol -not sure it is valid.

bibtexParseJs cannot parse the above bibtex entry because of the quote character and the percentage symbol.

Do you have a solution or a hint for the quote (") problem?

DerekDomino commented 10 years ago

Edit: I'm already pre-cleaning the BibTex entries with the following replacement rules before sending them to bibtexParseJs

var bibTeX = inspireTxt
    .replace(/[\n\r]/g, ' ') // remove carriage returns because title breaks "{... \n ...}" are not handled by bibtexParse
    .replace(/SLACcitation\s*=\s*"%%(.*);%%"\s*,/ig,'')  // remove field with percentage symbols
    .replace(/\s+/g, ' ');  // remove extraneous space/tabs ...
rcpeters commented 10 years ago

Title should be (http://tex.stackexchange.com/questions/65331/handling-quotes-inside-quotes-in-a-bibliographic-field)

  title          = {Warped Graviton "Z + Missing Energy" Signal at Hadron Colliders},

I'm still have to look into why % fails.