Brackets around words in .bib exports
I've often found that when using "add items by identifier" (usually DOI or ISBN) or using the browser extension to add items to my Zotero library, the entries will appear correctly in the Zotero desktop client, but will have idiosyncratic curly brackets {} around words in the title, author, etc. for the entry. For example, the below presents an Obama speech where the title has bracketed words.
@misc{obamaRemarksPresidentCampaignn2012,
address = {Roanoke},
type = {Transcript},
title = {Remarks by the {President} at a {Campaign} {Event} in {Roanoke}, {Virginia}},
url = {https://obamawhitehouse.archives.gov/the-press-office/2012/07/13/remarks-president-campaign-event-roanoke-virginia},
author = {Obama, Barack},
month = jul,
year = {2012},
}
Unfortunately, this can cause formatting issues with exported to e.g. BibTex. Typically, it creates large spaces around words and makes the bibliography largely unintelligible.
Anyone have any advice on how to address this behavior? Is this the result of some setting?
@misc{obamaRemarksPresidentCampaignn2012,
address = {Roanoke},
type = {Transcript},
title = {Remarks by the {President} at a {Campaign} {Event} in {Roanoke}, {Virginia}},
url = {https://obamawhitehouse.archives.gov/the-press-office/2012/07/13/remarks-president-campaign-event-roanoke-virginia},
author = {Obama, Barack},
month = jul,
year = {2012},
}
Unfortunately, this can cause formatting issues with exported to e.g. BibTex. Typically, it creates large spaces around words and makes the bibliography largely unintelligible.
Anyone have any advice on how to address this behavior? Is this the result of some setting?
It's actually easier to go sentence case to title case in my situation (very few proper nouns in titles and I can manually change thos)e, so just looking if anyone has implemented something to do this
If you open Tools -> Developer -> Run Javascript, check "Run as async function", and paste in this code
function sentenceCase(text) {
let haslowercase = false
const restore = []
let sentencecased = text.replace(/((?:^|[?!]|[-.:;\[\]<>'*\\(),{}_“”‘’])?\s*)([^-\s;?:.!\[\]<>'*\\(),{}_“”‘’]+)/g, (match, leader, word, offset) => {
if (word.match(/^[A-Z]$/)) {
const leaderlen = leader && leader.length
restore.push([offset + leaderlen, offset + leaderlen + word.length, word])
}
else if (word.match(/^[a-z]/)) {
haslowercase = true
}
if (leader && !leader.match(/^[?!]/) && word.match(/^[A-Z][^A-Z]*$/)) word = word.toLowerCase()
return (leader || '') + word
})
if (haslowercase) {
for (const [start, end, word] of restore) {
sentencecased = sentencecased.substr(0, start) + word + sentencecased.substr(end)
}
}
// restore protected parts from original
text.replace(/<span class="nocase">.*?<\/span>|<nc>.*?<\/nc>/gi, (match, offset) => {
sentencecased = sentencecased.substr(0, offset) + match + sentencecased.substr(offset + match.length)
return match
})
return sentencecased
}
for (const item of Zotero.getActiveZoteroPane().getSelectedItems()) {
if (!item.isRegularItem()) continue
const title = sentenceCase(item.getField('title'))
if (title === item.getField('title')) continue
item.setField('title', title)
await item.saveTx()
}
and click "Run", it will apply sentence casing to all items you have currently selected in Zotero. Inspecting the results is on you -- This one is a bit more refined than the Zotero sentence caser, but not much, and it has absolutely zero understanding of language (English or otherwise).
I'd need to see a sample of what's going wrong, but from the sounds of it, your bibtex pipeline is wonky.