Page 1 of 1

Parsing BE BiBTeX export to enforce Case in Titles

Posted: Mon May 22, 2017 10:47 pm
by iandol
When BE automatically exports to BiBTeX using Applescript, abbreviations/acronyms like DNA whose case should be preserved are not wrapped with { }[1]. This means that, depending on the bibliography style you end up with Dna etc. I've made a little script in Ruby which edits the .bib file titles and simply wraps each of a list of acronyms with { }. I use this from naupaka's applescript exporter which I've modified to run this Ruby script, but you can run it by itself using fixCase.rb MyFile.bib:

fixCase.rb: https://gist.github.com/iandol/90684eee ... fixcase-rb

bookends_to_bibtex.scpt: https://gist.github.com/iandol/90684eee ... 6762d5149e

You need to put both bookends_to_bibtex.scpt and fixCase.rb on your path and the run it like so:

Code: Select all

> bookends_to_bibtex.scpt "My Group" /my/output/directory/ DEBUG
The DEBUG at the end simply gives you a little log of what was done, if you omit it, the script is silent (no output).

You need to edit fixCase.rb keepUpper and makeUpper lists with your own acronyms. I split this into two lists: keepUpper wraps {} only if the item is already the right case, whereas makeUpper enforces case even if the item is not the preferred case.

The script is pretty quick, it takes around 0.8s to process a 5MB bibtex file...

----
[1] I use Pandoc and CSL, however { } to protect case is valid in both CSL and BibLaTeX according to the Pandoc citeproc instructions.

Re: Parsing BE BiBTeX export to enforce Case in Titles

Posted: Tue May 23, 2017 7:30 am
by Jon
In BibTeX preferences there is this option:

Bracket acronyms in title, e.g. {DNA}

Did that not work for you?

Jon
Sonny Software

Re: Parsing BE BiBTeX export to enforce Case in Titles

Posted: Tue May 23, 2017 8:47 am
by iandol
Hi Jon, I'm using the Applescript method "set myBibTex to «event ToySGUID» thisList given «class RRTF»:"false", string:"bibtex"" to fetch the bibtex, and the titles are not {protected} with the settings in Prefs > Scan & Bib > Don't change case:...

Re: Parsing BE BiBTeX export to enforce Case in Titles

Posted: Tue May 23, 2017 10:02 pm
by iandol
Hi Jon, I have also just tested manual export (File > Export References (Hits)... > BibTeX) and it doesn't seem to work. Now I naively assumed it would use the settings in "Sentence and Title Case" but rereading the manual and it is not clear, but it is not even bracketing acronyms the manual suggests it should, like 2D. Screenshot shows an export that contains 2D 3D and an entry in my Don't change case list, V4:
test.png
test.png (89.21 KiB) Viewed 17731 times

Re: Parsing BE BiBTeX export to enforce Case in Titles

Posted: Wed May 24, 2017 8:35 am
by Jon
It should bracket strings of uppercase letters. 2D works here. Make sure you have set the output encoding to BibTeX, not Styled Text or Plain Text.

Jon
Sonny Software

Re: Parsing BE BiBTeX export to enforce Case in Titles

Posted: Wed May 24, 2017 11:19 am
by iandol
OK I was using UTF-8. This is quite a confusing setting, as I can output RIS format using a BiBTeX "format", and the BiBTeX output is actually UTF-8 encoded! What is the BibTeX "encoding" actually doing that isn't just UTF-8 + the settings from Preferences? And although now {2D} is bracketed, all the entries on my don't change case list are not. It makes sense IMO to also bracket them.

Re: Parsing BE BiBTeX export to enforce Case in Titles

Posted: Wed May 24, 2017 11:33 am
by Jon
Output "as BibTeX" means that BibTeX markup will be used for styled text. This is independent of what format you're using (e.g. you could create a new format called My Format that is an edited version of the BibTeX format we supply, in which case you'd select BibTeX as the output markup. To make this more clear, in the next update I'll change the option in the Bibliography output dialog from "BibTeX" to "BibTeX Markup".

The "Bracket acronyms in title" setting in preferences has nothing to do with your "don't change case" list. It does what it says -- puts curly brackets around stretches of upper case acronyms. The "don't change case" list is only used when the format calls for the title field to be output in a special case (e.g. Title Case) and you want to preserve acronyms. It will have no effect if the title is output as entered (which is how the BibTeX format is set up).

Jon
Sonny Software

Re: Parsing BE BiBTeX export to enforce Case in Titles

Posted: Thu May 25, 2017 10:46 am
by iandol
OK so the fix case script still offers some useful functionality (more general in what can be protected, and preserve+enforce lists) not available within the bookends export...

Re: Parsing BE BiBTeX export to enforce Case in Titles

Posted: Fri Sep 14, 2018 11:15 pm
by Dellu
Jon wrote: Wed May 24, 2017 11:33 am The "Bracket acronyms in title" setting in preferences has nothing to do with your "don't change case" list. It does what it says -- puts curly brackets around stretches of upper case acronyms. The "don't change case" list is only used when the format calls for the title field to be output in a special case (e.g. Title Case) and you want to preserve acronyms. It will have no effect if the title is output as entered (which is how the BibTeX format is set up).

Jon
Sonny Software
I wish there is a way to customize the acronym list. I was also thinking the "don't change case" list is used for the same purpose.
I want the number of words to be exported as they are (under the braces) so that bibtex will not convert them to lower case.