python-bibtexparser icon indicating copy to clipboard operation
python-bibtexparser copied to clipboard

Do not assume that case in Title= field is correct

Open simsong opened this issue 5 years ago • 1 comments

Currently bibtexparser assumes that the letter case of the title= field is correct. It then escapes the case when it writes out the file, forcing it to be correct, and breaking bib styles that do not use title case for titles!

That is, this input:

@book{bug,
 title="Once Upon a Time.",
 author="Dr. Evil",
 year=2000
}

Becomes this output:

@book{bug,
 author = {Dr. Evil},
 title = {{O}nce {U}pon a {T}ime.},
 year = {2000}
}

Here is a demo program:

import sys
import io
import bibtexparser
from bibtexparser.bparser import BibTexParser
from bibtexparser.customization import homogenize_latex_encoding

INPUT = """
@book{bug,
 title="Once Upon a Time.",
 author="Dr. Evil",
 year=2000
}
"""

if __name__=="__main__":
    parser = BibTexParser()
    parser.customization = homogenize_latex_encoding
    bib_database = bibtexparser.load( io.StringIO(INPUT), parser=parser)

    print("INPUT:")
    print(INPUT)
    print("OUTPUT:")
    bibtexparser.dump(bib_database, sys.stdout)

Requested resolution:

  • [ ] bibtexparser should not default to preserving case through escaping.
  • [ ] bibtexparser should detect escapes, though, and preserve them.

simsong avatar Aug 03 '20 16:08 simsong

This is somehow related to the very old PR https://github.com/sciunto-org/python-bibtexparser/pull/126. Need to double check.

MiWeiss avatar Jul 09 '22 07:07 MiWeiss

V2 does not do any case preservation at the moment; we'll possibly add a corresponding middleware in the future. This would be optional to use. I thus consider this issue fixed in v2.

MiWeiss avatar May 27 '23 19:05 MiWeiss