Addresses #749, BibTeX issues
- import UTF-8 by default (as far as I can tell, this is no worse than the previous behavior, which would probably have read all BibTeX files as ASCII) - use only ascii characters in cite keys - present BibTeX UTF-8 export option on export - hide disabled export options, rather than graying them out, to avoid the indication that other formats will not be exported as UTF-8
This commit is contained in:
parent
6a71c39d91
commit
41221592b3
|
@ -109,6 +109,8 @@ var Zotero_File_Interface_Export = new function() {
|
|||
}
|
||||
|
||||
var optionsBox = document.getElementById("translator-options");
|
||||
optionsBox.hidden = true;
|
||||
var haveOption = false;
|
||||
for(var i=0; i<optionsBox.childNodes.length; i++) {
|
||||
// loop through options to see which should be enabled
|
||||
var node = optionsBox.childNodes[i];
|
||||
|
@ -116,7 +118,8 @@ var Zotero_File_Interface_Export = new function() {
|
|||
|
||||
if(translatorOptions[optionName] != undefined) {
|
||||
// option should be enabled
|
||||
node.disabled = undefined;
|
||||
optionsBox.hidden = undefined;
|
||||
node.hidden = undefined;
|
||||
|
||||
var defValue = translatorOptions[optionName];
|
||||
if(typeof(defValue) == "boolean") {
|
||||
|
@ -131,10 +134,12 @@ var Zotero_File_Interface_Export = new function() {
|
|||
}
|
||||
} else {
|
||||
// option should be disabled and unchecked to prevent confusion
|
||||
node.disabled = true;
|
||||
node.hidden = true;
|
||||
node.setAttribute("checked", "false");
|
||||
}
|
||||
}
|
||||
|
||||
window.sizeToContent();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -802,6 +802,21 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
|
|||
if(formattedString.format == "Sort") {
|
||||
// for sort, we use the plain names
|
||||
var name = creators[i].getNameVariable("lastName");
|
||||
|
||||
// cut off lowercase parts of otherwise capitalized names (e.g., "de")
|
||||
var lastNameParts = name.split(" ");
|
||||
if(lastNameParts.length > 1 && lastNameParts[0].length <= 4
|
||||
&& lastNameParts[0][0].toLowerCase() == lastNameParts[0][0]
|
||||
&& lastNameParts[lastNameParts.length-1][0].toUpperCase() == lastNameParts[lastNameParts.length-1][0]) {
|
||||
name = "";
|
||||
for(var k=1; k<lastNameParts.length; k++) {
|
||||
if(lastNameParts[k][0].toUpperCase() == lastNameParts[k][0]) {
|
||||
name += " "+lastNameParts[k];
|
||||
}
|
||||
}
|
||||
name = name.substr(1);
|
||||
}
|
||||
|
||||
var firstName = creators[i].getNameVariable("firstName");
|
||||
if(name && firstName) name += ", ";
|
||||
name += firstName;
|
||||
|
|
|
@ -661,8 +661,6 @@ Zotero.Translate.prototype._generateSandbox = function() {
|
|||
this._sandbox.Zotero.Utilities = new Zotero.Utilities();
|
||||
}
|
||||
|
||||
this._sandbox.Zotero.useBibtexUTF8 = Zotero.Prefs.get("export.unicodeBibTeX");
|
||||
|
||||
if(this.type == "export") {
|
||||
// add routines to retrieve items and collections
|
||||
this._sandbox.Zotero.nextItem = function() { return me._exportGetItem() };
|
||||
|
|
|
@ -451,6 +451,7 @@ fulltext.indexState.partial = Partial
|
|||
|
||||
exportOptions.exportNotes = Export Notes
|
||||
exportOptions.exportFileData = Export Files
|
||||
exportOptions.UTF8 = Export as UTF-8
|
||||
|
||||
date.daySuffixes = st, nd, rd, th
|
||||
date.abbreviation.year = y
|
||||
|
|
|
@ -61,7 +61,6 @@ pref("extensions.zotero.export.lastStyle", 'http://www.zotero.org/styles/chicago
|
|||
pref("extensions.zotero.export.bibliographySettings", 'save-as-rtf');
|
||||
pref("extensions.zotero.export.bibliographyLocale", '');
|
||||
pref("extensions.zotero.export.citePaperJournalArticleURL", false);
|
||||
pref("extensions.zotero.export.unicodeBibTeX", false);
|
||||
|
||||
pref("extensions.zotero.export.quickCopy.setting", 'bibliography=http://www.zotero.org/styles/chicago-note.csl');
|
||||
|
||||
|
|
44
scrapers.sql
44
scrapers.sql
|
@ -15780,8 +15780,9 @@ function doExport() {
|
|||
}
|
||||
}');
|
||||
|
||||
REPLACE INTO translators VALUES ('9cb70025-a888-4a29-a210-93ec52da40d4', '1.0.0b4.r1', '', '2007-12-12 12:00:00', '1', '100', '3', 'BibTeX', 'Simon Kornblith', 'bib',
|
||||
REPLACE INTO translators VALUES ('9cb70025-a888-4a29-a210-93ec52da40d4', '1.0.0b4.r1', '', '2007-12-16 03:13:58', '1', '100', '3', 'BibTeX', 'Simon Kornblith', 'bib',
|
||||
'Zotero.configure("dataMode", "block");
|
||||
Zotero.addOption("UTF8", false);
|
||||
|
||||
function detectImport() {
|
||||
var block = "";
|
||||
|
@ -17482,10 +17483,8 @@ function doImport() {
|
|||
var read = "", text = "", recordCloseElement = false;
|
||||
var type = false;
|
||||
|
||||
if (Zotero.useBibtexUTF8) {
|
||||
Zotero.debug("Setting UTF-8 on import");
|
||||
Zotero.setCharacterSet("UTF-8");
|
||||
}
|
||||
Zotero.setCharacterSet("UTF-8");
|
||||
|
||||
while(read = Zotero.read(1)) {
|
||||
if(read == "@") {
|
||||
type = "";
|
||||
|
@ -17511,7 +17510,7 @@ function writeMacroField(field, value) {
|
|||
}
|
||||
|
||||
Zotero.write(",\n\t"+field+" = ");
|
||||
if (!Zotero.useBibtexUTF8) {
|
||||
if (!Zotero.getOption("UTF8")) {
|
||||
var tvalue = value.toString();
|
||||
value = "";
|
||||
for (var j in tvalue) {
|
||||
|
@ -17529,7 +17528,7 @@ function writeMacroField(field, value) {
|
|||
function writeField(field, value) {
|
||||
if(!value) return;
|
||||
Zotero.write(",\n\t"+field+" = {");
|
||||
if (!Zotero.useBibtexUTF8) {
|
||||
if (!Zotero.getOption("UTF8")) {
|
||||
var tvalue = value.toString();
|
||||
value = "";
|
||||
for (var j in tvalue) {
|
||||
|
@ -17547,8 +17546,7 @@ function writeField(field, value) {
|
|||
|
||||
var numberRe = /^[0-9]+/;
|
||||
function doExport() {
|
||||
if (Zotero.useBibtexUTF8) {
|
||||
Zotero.debug("Setting UTF-8 on import");
|
||||
if(Zotero.getOption("UTF8")) {
|
||||
Zotero.setCharacterSet("UTF-8");
|
||||
}
|
||||
|
||||
|
@ -17565,33 +17563,37 @@ function doExport() {
|
|||
// create a unique citation key
|
||||
var basekey = "";
|
||||
if(item.creators && item.creators[0] && item.creators[0].lastName) {
|
||||
basekey = item.creators[0].lastName.toLowerCase().replace(/ /g,"_").replace(/,/g,"");
|
||||
basekey += "_" + item.creators[0].lastName.toLowerCase().replace(/ /g,"_").replace(/,/g,"");
|
||||
}
|
||||
|
||||
// include the item title as part of the citation key
|
||||
if (item["title"]) {
|
||||
// this is a list of words that should not appear as part of the citation key
|
||||
var bannedTitleKeys = {"a" : 1, "an" : 1, "does": 1, "how": 1, "it''s": 1, "on" : 1, "some": 1, "the" : 1, "this" : 1, "why" : 1 };
|
||||
var titleElements = item["title"].split(" ");
|
||||
var appendKey = "";
|
||||
for (te in titleElements) {
|
||||
if (!bannedTitleKeys[titleElements[te].toLowerCase()]) {
|
||||
appendKey = "_" + titleElements[te].toLowerCase() + "_";
|
||||
var bannedTitleKeys = ["a", "an", "from", "does", "how", "it''s", "its", "on", "some", "the", "this", "why"];
|
||||
var titleElements = item["title"].toLowerCase().split(" ");
|
||||
for(var te in titleElements) {
|
||||
if (bannedTitleKeys.indexOf(titleElements[te]) == -1) {
|
||||
basekey += "_" + titleElements[te];
|
||||
break;
|
||||
}
|
||||
}
|
||||
basekey = basekey + appendKey;
|
||||
}
|
||||
}
|
||||
|
||||
if(item.date) {
|
||||
var date = Zotero.Utilities.strToDate(item.date);
|
||||
if(date.year && numberRe.test(date.year)) {
|
||||
basekey += date.year;
|
||||
basekey += "_" + date.year;
|
||||
}
|
||||
}
|
||||
|
||||
// make sure we do not have any other funny characters
|
||||
basekey = basekey.replace(/[\. ,'':\"!&]/g,"");
|
||||
// for now, remove any characters not explicitly known to be allowed;
|
||||
// we might want to allow UTF-8 citation keys in the future, depending
|
||||
// on implementation support.
|
||||
//
|
||||
// no matter what, we want to make sure we exclude
|
||||
// " # % '' ( ) , = { } ~ and backslash
|
||||
|
||||
basekey = basekey.substr(1).replace(/[^a-z0-9\!\$\&\*\+\-\.\/\:\;\<\>\?\[\]\^\_\`\|]+/g,"");
|
||||
var citekey = basekey;
|
||||
var i = 0;
|
||||
while(citekeys[citekey]) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user