Start with alwaysMap and follow. You'll find lots of maps.
The below hack no longer works because the code has changed a lot since then.
- Open
BibTeX.jsin thezotero/translatorsdirectory. - Try searching for
alwaysMapand commenting out the baddies. - Search for
function escapeSpecialCharactersand remove the first args of thereplacecommands corresponding to the characters you don't want edited. - Restart Zotero.
If you want to just stop all escape character editing, return str.
Here's my code from 2018
// See http://tex.stackexchange.com/questions/230750/open-brace-in-bibtex-fields/230754
var vphantomRe = /\\vphantom{\\}}((?:.(?!\\vphantom{\\}}))*)\\vphantom{\\{}/g;
function escapeSpecialCharacters(str) {
//replace(/[\{\}]/g, function(c) { return alwaysMap[c] })
var newStr = str.replace(/([\#\%\&])/g, "\\$1");
// We escape each brace in the text by making sure that it has a counterpart,
// but sometimes this is overkill if the brace already has a counterpart in
// the text.
if (newStr.indexOf('\\vphantom') != -1) {
var m;
while (m = vphantomRe.exec(newStr)) {
// Can't use a simple replace, because we want to match up inner with inner
// and outer with outer
newStr = newStr.substr(0,m.index) + m[1] + newStr.substr(m.index + m[0].length);
vphantomRe.lastIndex = 0; // Start over, because the previous replacement could have created a new pair
}
}
return newStr;
}
- Find your profile.
- Go under the zotero\translators and edit the BibTeX.js file
- Change line the "alwaysMap" array (line 1528) from the following:
var alwaysMap = { "|":"{\textbar}", "<":"{\textless}", ">":"{\textgreater}", "~":"{\textasciitilde}", "^":"{\textasciicircum}", "\":"{\textbackslash}" };
to the following
var alwaysMap = { "|":"{\textbar}", "<":"{\textless}", ">":"{\textgreater}" //, // "~":"{\textasciitilde}", // "^":"{\textasciicircum}" // "\":"{\textbackslash}" };
This will remove escaping ~, ^ and .
Now change the following on line 1806:
value = value.replace(/[|<>~^\]/g, mapEscape).replace(/([#$%&_])/g, "\$1");
to the following:
value = value.replace(/[|<>]/g, mapEscape).replace(/([#%&])/g, "\$1");
- Save the file. You won't even need to restart Firefox!
Awesome. I'm a happy tomato. Sorry for the trouble and thanks again for the help!