FlamingTempura / bibtex-tidy

Cleaner and Formatter for BibTeX files
https://flamingtempura.github.io/bibtex-tidy/
MIT License
832 stars 63 forks source link

Double braces fail with braces in text #410

Closed jonas-eschle closed 4 months ago

jonas-eschle commented 1 year ago

Currently, the " can be replaced by {, but this will render titles with special characters problematic. Is there an option available, or can one be added, to have a " be replaced by {" for example?

FlamingTempura commented 12 months ago

Could you give an example of some bibtex where this would be useful and what you'd expect the output to be?

jonas-eschle commented 12 months ago

I think I figured that the problem is actually a bug in bibtex, not a fundamental issue. Something goes very wrong with the replacement:

minimal example

@article{mypaper,
    title = "{a is {b}}",
}

with "enclose values in double brackets" for the title results in

@article{mypaper,
    title        = {{a is b}}
}

Another, longer example with another brace screw up

@article{LHCb-PAPER-2020-001,
    author = "Aaij, R. and others",
    title = "{Search for the rare decays \mbox{\decay{\Bs}{\epem}} and \mbox{\decay{\Bd}{\epem}}}",
    collaboration = "LHCb collaboration",
    report = "{LHCb-PAPER-2020-001 CERN-EP-2020-023}",
    eprint = "2003.03999",
    archivePrefix = "arXiv",
    primaryClass = "hep-ex",
    year = "2020",
    journal = "Phys. Rev. Lett.",
    volume = "124",
    pages = "211802",
    doi = "10.1103/PhysRevLett.124.211802",
}

becomes

@article{LHCb-PAPER-2020-001,
    title        = {{Search for the rare decays \mbox{\decay{\Bs}{\epem}} and \mbox{\decay{\Bd}{\epem}}}}}}}}}}},
    author       = {Aaij, R. and others},
    year         = 2020,
    journal      = {Phys. Rev. Lett.},
    volume       = 124,
    pages        = 211802,
    doi          = {10.1103/PhysRevLett.124.211802},
    collaboration = {LHCb collaboration},
    report       = {{LHCb-PAPER-2020-001 CERN-EP-2020-023}},
    eprint       = {2003.03999},
    archiveprefix = {arXiv},
    primaryclass = {hep-ex}
}

with a ton of braces that are left open.

jonas-eschle commented 11 months ago

Hi @FlamingTempura , just wondering if you could reproduce it and maybe had the time to take a look at it?

FlamingTempura commented 11 months ago

Hey - thanks for reporting back with reproduction steps, I've not had a chance to look into this yet but can confirm it's a bug in bibtex-tidy.

Can't promise when I'll be able to fix it. I'd welcome a pull request if it's something you'd be up for investigating.

FlamingTempura commented 4 months ago

This should now be fixed in web UI and v1.12.0.

Output for the above example:

@article{LHCb-PAPER-2020-001,
    title        = {{Search for the rare decays \mbox{\decay{\Bs}{\epem}} and \mbox{\decay{\Bd}{\epem}}}},
    author       = {Aaij, R. and others},
    year         = 2020,
    journal      = {Phys. Rev. Lett.},
    volume       = 124,
    pages        = 211802,
    doi          = {10.1103/PhysRevLett.124.211802},
    collaboration = {LHCb collaboration},
    report       = {{LHCb-PAPER-2020-001 CERN-EP-2020-023}},
    eprint       = {2003.03999},
    archiveprefix = {arXiv},
    primaryclass = {hep-ex}
}

If this hasn't solved the issue then please reopen the ticket.