Merge branch 'kill-e4x'
Conflicts: chrome/content/zotero/xpcom/integration.js
This commit is contained in:
commit
57c3d190b4
7 changed files with 135 additions and 1590 deletions
|
@ -293,13 +293,14 @@ Zotero.Cite.makeFormattedBibliography = function(cslEngine, format) {
|
|||
if(lineSpacing == NaN) throw "Invalid linespacing";
|
||||
|
||||
var str;
|
||||
default xml namespace = ''; with({});
|
||||
try {
|
||||
XML.prettyPrinting = false;
|
||||
XML.ignoreWhitespace = false;
|
||||
var xml = new XML(html);
|
||||
try {
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser),
|
||||
doc = parser.parseFromString(html, "application/xml");
|
||||
|
||||
var multiField = !!xml..div.(@class == "csl-left-margin").length();
|
||||
var leftMarginDivs = Zotero.Utilities.xpath(doc, '//div[@class="csl-left-margin"]'),
|
||||
multiField = !!leftMarginDivs.length,
|
||||
clearEntries = multiField;
|
||||
|
||||
// One of the characters is usually a period, so we can adjust this down a bit
|
||||
maxOffset = Math.max(1, maxOffset - 2);
|
||||
|
@ -307,7 +308,9 @@ Zotero.Cite.makeFormattedBibliography = function(cslEngine, format) {
|
|||
// Force a minimum line height
|
||||
if(lineSpacing <= 1.35) lineSpacing = 1.35;
|
||||
|
||||
xml.@style += "line-height: " + lineSpacing + "; ";
|
||||
var style = doc.documentElement.getAttribute("style");
|
||||
if(!style) style = "";
|
||||
style += "line-height: " + lineSpacing + "; ";
|
||||
|
||||
if(hangingIndent) {
|
||||
if (multiField && !secondFieldAlign) {
|
||||
|
@ -315,32 +318,28 @@ Zotero.Cite.makeFormattedBibliography = function(cslEngine, format) {
|
|||
}
|
||||
// If only one field, apply hanging indent on root
|
||||
else if (!multiField) {
|
||||
xml.@style += "padding-left: " + hangingIndent + "em; text-indent:-" + hangingIndent + "em;";
|
||||
style += "padding-left: " + hangingIndent + "em; text-indent:-" + hangingIndent + "em;";
|
||||
}
|
||||
}
|
||||
|
||||
var leftMarginDivs = xml..div.(@class == "csl-left-margin");
|
||||
var clearEntries = leftMarginDivs.length() > 0;
|
||||
if(style) doc.documentElement.setAttribute("style", style);
|
||||
|
||||
// csl-entry
|
||||
var divs = xml..div.(@class == "csl-entry");
|
||||
var num = divs.length();
|
||||
var i = 0;
|
||||
for each(var div in divs) {
|
||||
var first = i == 0;
|
||||
var last = i == num - 1;
|
||||
var divs = Zotero.Utilities.xpath(doc, '//div[@class="csl-entry"]');
|
||||
for(var i=0, n=divs.length; i<n; i++) {
|
||||
var div = divs[i],
|
||||
divStyle = div.getAttribute("style");
|
||||
if(!divStyle) divStyle = "";
|
||||
|
||||
if (clearEntries) {
|
||||
div.@style += "clear: left; ";
|
||||
divStyle += "clear: left; ";
|
||||
}
|
||||
|
||||
if(entrySpacing) {
|
||||
if(!last) {
|
||||
div.@style += "margin-bottom: " + entrySpacing + "em;";
|
||||
}
|
||||
if(entrySpacing && i !== n - 1) {
|
||||
divStyle += "margin-bottom: " + entrySpacing + "em;";
|
||||
}
|
||||
|
||||
i++;
|
||||
if(divStyle) div.setAttribute("style", divStyle);
|
||||
}
|
||||
|
||||
// Padding on the label column, which we need to include when
|
||||
|
@ -349,32 +348,44 @@ Zotero.Cite.makeFormattedBibliography = function(cslEngine, format) {
|
|||
|
||||
// div.csl-left-margin
|
||||
for each(var div in leftMarginDivs) {
|
||||
div.@style = "float: left; padding-right: " + rightPadding + "em;";
|
||||
var divStyle = div.getAttribute("style");
|
||||
if(!divStyle) divStyle = "";
|
||||
|
||||
divStyle = "float: left; padding-right: " + rightPadding + "em;";
|
||||
|
||||
// Right-align the labels if aligning second line, since it looks
|
||||
// better and we don't need the second line of text to align with
|
||||
// the left edge of the label
|
||||
if (secondFieldAlign) {
|
||||
div.@style += "text-align: right; width: " + maxOffset + "em;";
|
||||
divStyle += "text-align: right; width: " + maxOffset + "em;";
|
||||
}
|
||||
|
||||
div.setAttribute("style", divStyle);
|
||||
}
|
||||
|
||||
// div.csl-right-inline
|
||||
for each(var div in xml..div.(@class == "csl-right-inline")) {
|
||||
div.@style = "margin: 0 .4em 0 " + (secondFieldAlign ? maxOffset + rightPadding : "0") + "em;";
|
||||
for each(var div in Zotero.Utilities.xpath(doc, '//div[@class="csl-right-inline"]')) {
|
||||
var divStyle = div.getAttribute("style");
|
||||
if(!divStyle) divStyle = "";
|
||||
|
||||
divStyle = "margin: 0 .4em 0 " + (secondFieldAlign ? maxOffset + rightPadding : "0") + "em;";
|
||||
|
||||
if (hangingIndent) {
|
||||
div.@style += "padding-left: " + hangingIndent + "em; text-indent:-" + hangingIndent + "em;";
|
||||
divSstyle += "padding-left: " + hangingIndent + "em; text-indent:-" + hangingIndent + "em;";
|
||||
}
|
||||
|
||||
div.setAttribute("style", divStyle);
|
||||
}
|
||||
|
||||
// div.csl-indent
|
||||
for each(var div in xml..div.(@class == "csl-indent")) {
|
||||
div.@style = "margin: .5em 0 0 2em; padding: 0 0 .2em .5em; border-left: 5px solid #ccc;";
|
||||
for each(var div in Zotero.Utilities.xpath(doc, '//div[@class="csl-indent"]')) {
|
||||
div.setAttribute("style", "margin: .5em 0 0 2em; padding: 0 0 .2em .5em; border-left: 5px solid #ccc;");
|
||||
}
|
||||
|
||||
//Zotero.debug(xml);
|
||||
str = xml.toXMLString();
|
||||
var s = Components.classes["@mozilla.org/xmlextras/xmlserializer;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMSerializer);
|
||||
str = s.serializeToString(doc);
|
||||
} finally {
|
||||
XML.prettyPrinting = true;
|
||||
XML.ignoreWhitespace = true;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2992,55 +2992,35 @@ Zotero.Integration.DocumentData = function(string) {
|
|||
* Serializes document-specific data as XML
|
||||
*/
|
||||
Zotero.Integration.DocumentData.prototype.serializeXML = function() {
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser);
|
||||
var doc = parser.parseFromString("<data/>", "application/xml");
|
||||
|
||||
var xmlData = doc.documentElement;
|
||||
xmlData.setAttribute("data-version", DATA_VERSION);
|
||||
xmlData.setAttribute("zotero-version", Zotero.version);
|
||||
|
||||
var session = doc.createElement("session");
|
||||
session.setAttribute("id", this.sessionID);
|
||||
xmlData.appendChild(session);
|
||||
|
||||
var style = doc.createElement("style");
|
||||
style.setAttribute("id", this.style.styleID);
|
||||
style.setAttribute("hasBibliography", this.style.hasBibliography ? 1 : 0);
|
||||
style.setAttribute("bibliographyStyleHasBeenSet", this.style.bibliographyStyleHasBeenSet ? 1 : 0);
|
||||
xmlData.appendChild(style);
|
||||
|
||||
var prefs = doc.createElement("prefs");
|
||||
var prefs = "";
|
||||
for(var pref in this.prefs) {
|
||||
var prefXML = doc.createElement("pref");
|
||||
prefXML.setAttribute("name", pref);
|
||||
prefXML.setAttribute("value", this.prefs[pref]);
|
||||
prefs.appendChild(prefXML);
|
||||
prefs += '<pref name="'+Zotero.Utilities.htmlSpecialChars(pref)+'" '+
|
||||
'value="'+Zotero.Utilities.htmlSpecialChars(this.prefs[pref])+'"/>';
|
||||
}
|
||||
xmlData.appendChild(prefs);
|
||||
|
||||
var domSerializer = Components.classes["@mozilla.org/xmlextras/xmlserializer;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMSerializer);
|
||||
return domSerializer.serializeToString(doc);
|
||||
return '<data data-version="'+Zotero.Utilities.htmlSpecialChars(DATA_VERSION)+'" '+
|
||||
'zotero-version="'+Zotero.Utilities.htmlSpecialChars(Zotero.version)+'">'+
|
||||
'<session id="'+Zotero.Utilities.htmlSpecialChars(this.sessionID)+'"/>'+
|
||||
'<style id="'+Zotero.Utilities.htmlSpecialChars(this.style.styleID)+'" '+
|
||||
'hasBibliography="'+(this.style.hasBibliography ? "1" : "0")+'" '+
|
||||
'bibliographyStyleHasBeenSet="'+(this.style.bibliographyStyleHasBeenSet ? "1" : "0)+'"/>'+
|
||||
(prefs ? '<prefs>'+prefs+'</prefs>' : '<prefs/>')+'</data>';
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Unserializes document-specific XML
|
||||
*/
|
||||
Zotero.Integration.DocumentData.prototype.unserializeXML = function(xmlData) {
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser);
|
||||
xmlData = parser.parseFromString(xmlData, "application/xml").documentElement;
|
||||
.createInstance(Components.interfaces.nsIDOMParser),
|
||||
doc = parser.parseFromString(xmlData, "application/xml");
|
||||
|
||||
this.sessionID = Zotero.Utilities.xpathText(xmlData, "session/@id");
|
||||
this.style = {
|
||||
"styleID":Zotero.Utilities.xpathText(xmlData, "style/@id"),
|
||||
"hasBibliography":(Zotero.Utilities.xpathText(xmlData, "style/@hasBibliography") == "1"),
|
||||
"bibliographyStyleHasBeenSet":(Zotero.Utilities.xpathText(xmlData, "style/@bibliographyStyleHasBeenSet") == "1")
|
||||
};
|
||||
this.sessionID = Zotero.Utilities.xpathText(doc, '/data/session[1]/@id');
|
||||
this.style = {"styleID":Zotero.Utilities.xpathText(doc, '/data/style[1]/@id'),
|
||||
"hasBibliography":(Zotero.Utilities.xpathText(doc, '/data/style[1]/@hasBibliography') == 1),
|
||||
"bibliographyStyleHasBeenSet":(Zotero.Utilities.xpathText(doc, '/data/style[1]/@bibliographyStyleHasBeenSet') == 1)};
|
||||
this.prefs = {};
|
||||
for each(var pref in Zotero.Utilities.xpath(xmlData, "prefs/pref")) {
|
||||
for each(var pref in Zotero.Utilities.xpath(doc, '/data/prefs[1]/pref')) {
|
||||
var name = pref.getAttribute("name");
|
||||
var value = pref.getAttribute("value");
|
||||
if(value === "true") {
|
||||
|
@ -3052,9 +3032,9 @@ Zotero.Integration.DocumentData.prototype.unserializeXML = function(xmlData) {
|
|||
this.prefs[name] = value;
|
||||
}
|
||||
if(this.prefs["storeReferences"] === undefined) this.prefs["storeReferences"] = false;
|
||||
this.zoteroVersion = xmlData.getAttribute("zotero-version");
|
||||
this.zoteroVersion = doc.documentElement.getAttribute("zotero-version");
|
||||
if(!this.zoteroVersion) this.zoteroVersion = "2.0";
|
||||
this.dataVersion = xmlData.getAttribute("data-version");
|
||||
this.dataVersion = doc.documentElement.getAttribute("data-version");
|
||||
if(!this.dataVersion) this.dataVersion = 2;
|
||||
};
|
||||
|
||||
|
|
|
@ -36,6 +36,10 @@ Zotero.Styles = new function() {
|
|||
this.ios = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService);
|
||||
|
||||
this.ns = {
|
||||
"csl":"http://purl.org/net/xbiblio/csl"
|
||||
};
|
||||
|
||||
/**
|
||||
* Initializes styles cache, loading metadata for styles into memory
|
||||
*/
|
||||
|
@ -68,8 +72,11 @@ Zotero.Styles = new function() {
|
|||
var i = 0;
|
||||
var contents = dir.directoryEntries;
|
||||
while(contents.hasMoreElements()) {
|
||||
var file = contents.getNext().QueryInterface(Components.interfaces.nsIFile);
|
||||
if(!file.leafName || file.leafName[0] == "." || file.isDirectory()) continue;
|
||||
var file = contents.getNext().QueryInterface(Components.interfaces.nsIFile),
|
||||
filename = file.leafName;
|
||||
if(!filename || filename[0] === "."
|
||||
|| filename.substr(-4).toLowerCase() !== ".csl"
|
||||
|| file.isDirectory()) continue;
|
||||
|
||||
try {
|
||||
var style = new Zotero.Style(file);
|
||||
|
@ -149,78 +156,56 @@ Zotero.Styles = new function() {
|
|||
* are silenced as well
|
||||
*/
|
||||
this.install = function(style, loadURI, hidden) {
|
||||
// "with ({});" needed to fix default namespace scope issue
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=330572
|
||||
default xml namespace = "http://purl.org/net/xbiblio/csl"; with ({});
|
||||
const pathRe = /[^\/]+$/;
|
||||
|
||||
if(!_initialized || !this.cacheTranslatorData) this.init();
|
||||
|
||||
var type = "csl";
|
||||
|
||||
// handle nsIFiles
|
||||
var styleFile = null;
|
||||
if(style instanceof Components.interfaces.nsIFile) {
|
||||
styleFile = style;
|
||||
loadURI = style.leafName;
|
||||
if(loadURI.substr(-4) == ".ens") {
|
||||
type = "ens";
|
||||
style = Zotero.File.getBinaryContents(styleFile);
|
||||
} else {
|
||||
style = Zotero.File.getContents(styleFile);
|
||||
}
|
||||
style = Zotero.File.getContents(styleFile);
|
||||
}
|
||||
|
||||
var error = false;
|
||||
try {
|
||||
if(type == "ens") {
|
||||
// EN style
|
||||
var type = "ens";
|
||||
var enConverter = new Zotero.ENConverter(style);
|
||||
var xml = enConverter.parse();
|
||||
} else {
|
||||
// CSL
|
||||
var xml = this.cleanXML(style);
|
||||
if (!xml.name()) {
|
||||
throw new Error("File is not XML");
|
||||
}
|
||||
// CSL
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser),
|
||||
doc = parser.parseFromString(style, "application/xml");
|
||||
if (!doc.documentElement.localName) {
|
||||
throw new Error("File is not XML");
|
||||
}
|
||||
} catch(e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
if(!xml || error) {
|
||||
if(!doc || error) {
|
||||
if(!hidden) alert(Zotero.getString('styles.installError', loadURI));
|
||||
if(error) throw error;
|
||||
return false;
|
||||
}
|
||||
|
||||
var source = null;
|
||||
var styleID = xml.info.id.toString();
|
||||
if(type == "ens") {
|
||||
var title = styleFile.leafName.substr(0, styleFile.leafName.length-4);
|
||||
var fileName = styleFile.leafName;
|
||||
} else {
|
||||
// get file name from URL
|
||||
var m = pathRe.exec(styleID);
|
||||
var fileName = Zotero.File.getValidFileName(m ? m[0] : styleID);
|
||||
var title = xml.info.title.toString();
|
||||
|
||||
// look for a parent
|
||||
for each(var link in xml.info.link) {
|
||||
if(link.@rel == "source" || link.@rel == "independent-parent") {
|
||||
source = link.@href.toString();
|
||||
if(source == styleID) {
|
||||
if(!hidden) alert(Zotero.getString('styles.installError', loadURI));
|
||||
throw "Style with ID "+this.styleID+" references itself as source";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
var styleID = Zotero.Utilities.xpathText(doc, '/csl:style/csl:info[1]/csl:id[1]',
|
||||
Zotero.Styles.ns);
|
||||
// get file name from URL
|
||||
var m = pathRe.exec(styleID);
|
||||
var fileName = Zotero.File.getValidFileName(m ? m[0] : styleID);
|
||||
var title = Zotero.Utilities.xpathText(doc, '/csl:style/csl:info[1]/csl:title[1]',
|
||||
Zotero.Styles.ns);
|
||||
|
||||
// look for a parent
|
||||
var source = Zotero.Utilities.xpathText(doc,
|
||||
'/csl:style/csl:info[1]/csl:link[@rel="source" or @rel="independent-parent"][1]/@href',
|
||||
Zotero.Styles.ns);
|
||||
if(source == styleID) {
|
||||
if(!hidden) alert(Zotero.getString('styles.installError', loadURI));
|
||||
throw "Style with ID "+styleID+" references itself as source";
|
||||
}
|
||||
|
||||
// ensure csl or ens extension
|
||||
if(fileName.substr(-4).toLowerCase() != "."+type) fileName += "."+type;
|
||||
// ensure csl extension
|
||||
if(fileName.substr(-4).toLowerCase() != ".csl") fileName += ".csl";
|
||||
|
||||
var destFile = Zotero.getStylesDirectory();
|
||||
var destFileHidden = destFile.clone();
|
||||
|
@ -255,9 +240,8 @@ Zotero.Styles = new function() {
|
|||
|
||||
// also look for an existing style with the same title
|
||||
if(!existingFile) {
|
||||
var styleTitle = xml.info.title.toString();
|
||||
for each(var existingStyle in this.getAll()) {
|
||||
if(styleTitle === existingStyle.title) {
|
||||
if(title === existingStyle.title) {
|
||||
existingFile = existingStyle.file;
|
||||
existingTitle = existingStyle.title;
|
||||
break;
|
||||
|
@ -319,13 +303,6 @@ Zotero.Styles = new function() {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
this.cleanXML = function(str) {
|
||||
// this is where this should happen
|
||||
str = str.replace(/\s*<\?[^>]*\?>\s*\n/g, "");
|
||||
var ret = new XML(str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes installing a style, copying the file, reloading the style cache, and refreshing the
|
||||
|
@ -365,7 +342,7 @@ Zotero.Styles = new function() {
|
|||
* @class Represents a style file and its metadata
|
||||
* @property {nsIFile} file The path to the style file
|
||||
* @property {String} styleID
|
||||
* @property {String} type "csl" for CSL styles, "ens" for legacy styles
|
||||
* @property {String} type "csl" for CSL styles
|
||||
* @property {String} title
|
||||
* @property {String} updated SQL-style date updated
|
||||
* @property {String} class "in-text" or "note"
|
||||
|
@ -384,43 +361,33 @@ Zotero.Style = function(arg) {
|
|||
throw "Invalid argument passed to Zotero.Style";
|
||||
}
|
||||
|
||||
var extension = (typeof arg === "string" ? ".csl" : arg.leafName.substr(-4).toLowerCase());
|
||||
if(extension == ".ens") {
|
||||
this.type = "ens";
|
||||
|
||||
this.styleID = Zotero.Styles.ios.newFileURI(this.file).spec;
|
||||
this.title = this.file.leafName.substr(0, this.file.leafName.length-4);
|
||||
this.updated = Zotero.Date.dateToSQL(new Date(this.file.lastModifiedTime));
|
||||
this._version = "0.8";
|
||||
} else if(extension == ".csl") {
|
||||
// "with ({});" needed to fix default namespace scope issue
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=330572
|
||||
default xml namespace = "http://purl.org/net/xbiblio/csl"; with ({});
|
||||
|
||||
this.type = "csl";
|
||||
|
||||
var xml = Zotero.Styles.cleanXML(typeof arg === "string" ? arg : Zotero.File.getContents(arg));
|
||||
|
||||
this.styleID = xml.info.id.toString();
|
||||
this.title = xml.info.title.toString();
|
||||
this.updated = xml.info.updated.toString().replace(/(.+)T([^\+]+)\+?.*/, "$1 $2");
|
||||
this.categories = [category.@term.toString() for each(category in xml.info) if(category.@term.length())];
|
||||
this._class = xml.@class.toString();
|
||||
this._hasBibliography = !!xml.bibliography.length();
|
||||
this._version = xml.@version.toString();
|
||||
if(this._version == "") this._version = "0.8";
|
||||
|
||||
this.source = null;
|
||||
for each(var link in xml.info.link) {
|
||||
if(link.@rel == "source" || link.@rel == "independent-parent") {
|
||||
this.source = link.@href.toString();
|
||||
if(this.source == this.styleID) {
|
||||
throw "Style with ID "+this.styleID+" references itself as source";
|
||||
this.source = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.type = "csl";
|
||||
|
||||
var style = typeof arg === "string" ? arg : Zotero.File.getContents(arg),
|
||||
parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser),
|
||||
doc = parser.parseFromString(style, "application/xml");
|
||||
|
||||
this.styleID = Zotero.Utilities.xpathText(doc, '/csl:style/csl:info[1]/csl:id[1]',
|
||||
Zotero.Styles.ns);
|
||||
this.title = Zotero.Utilities.xpathText(doc, '/csl:style/csl:info[1]/csl:title[1]',
|
||||
Zotero.Styles.ns);
|
||||
this.updated = Zotero.Utilities.xpathText(doc, '/csl:style/csl:info[1]/csl:updated[1]',
|
||||
Zotero.Styles.ns).replace(/(.+)T([^\+]+)\+?.*/, "$1 $2");
|
||||
this.categories = [category.getAttribute("term")
|
||||
for each(category in Zotero.Utilities.xpath(doc,
|
||||
'/csl:style/csl:info[1]/csl:category', Zotero.Styles.ns))
|
||||
if(category.hasAttribute("term"))];
|
||||
this._class = doc.documentElement.getAttribute("class");
|
||||
this._hasBibliography = !!doc.getElementsByTagName("bibliography").length;
|
||||
this._version = doc.documentElement.getAttribute("version");
|
||||
if(!this._version) this._version = "0.8";
|
||||
|
||||
this.source = Zotero.Utilities.xpathText(doc,
|
||||
'/csl:style/csl:info[1]/csl:link[@rel="source" or @rel="independent-parent"][1]/@href',
|
||||
Zotero.Styles.ns);
|
||||
if(this.source === this.styleID) {
|
||||
throw "Style with ID "+this.styleID+" references itself as source";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -513,13 +480,6 @@ function() {
|
|||
}
|
||||
return parentStyle.hasBibliography;
|
||||
}
|
||||
|
||||
if(!this._hasBibliography) {
|
||||
// if we don't know whether this style has a bibliography, it's because it's an ens style
|
||||
// and we have to parse it to know
|
||||
this.getXML();
|
||||
}
|
||||
|
||||
return this._hasBibliography;
|
||||
});
|
||||
|
||||
|
@ -548,24 +508,9 @@ function() {
|
|||
* @type String
|
||||
*/
|
||||
Zotero.Style.prototype.getXML = function() {
|
||||
// "with ({});" needed to fix default namespace scope issue
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=330572
|
||||
default xml namespace = "http://purl.org/net/xbiblio/csl"; with ({});
|
||||
|
||||
if(this.type == "ens") {
|
||||
// EN style
|
||||
var string = Zotero.File.getBinaryContents(this.file);
|
||||
var enConverter = new Zotero.ENConverter(string, null, this.title);
|
||||
var xml = enConverter.parse();
|
||||
this._class = xml.@class.toString();
|
||||
this._hasBibliography = !!xml.bibliography.length();
|
||||
|
||||
return xml.toXMLString();
|
||||
} else {
|
||||
var indepFile = this.independentFile;
|
||||
if(indepFile) return Zotero.File.getContents(indepFile);
|
||||
return this.string;
|
||||
}
|
||||
var indepFile = this.independentFile;
|
||||
if(indepFile) return Zotero.File.getContents(indepFile);
|
||||
return this.string;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -304,24 +304,19 @@ Zotero.Utilities = {
|
|||
* @type String
|
||||
*/
|
||||
"htmlSpecialChars":function(/**String*/ str) {
|
||||
if (typeof str != 'string') {
|
||||
throw "Argument '" + str + "' must be a string in Zotero.Utilities.htmlSpecialChars()";
|
||||
}
|
||||
if (typeof str != 'string') str = str.toString();
|
||||
|
||||
if (!str) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var chars = ['&', '"',"'",'<','>'];
|
||||
var entities = ['amp', 'quot', 'apos', 'lt', 'gt'];
|
||||
|
||||
var newString = str;
|
||||
for (var i = 0; i < chars.length; i++) {
|
||||
var re = new RegExp(chars[i], 'g');
|
||||
newString = newString.replace(re, '&' + entities[i] + ';');
|
||||
}
|
||||
|
||||
newString = newString.replace(/<ZOTERO([^\/]+)\/>/g, function (str, p1, offset, s) {
|
||||
return str
|
||||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/<ZOTERO([^\/]+)\/>/g, function (str, p1, offset, s) {
|
||||
switch (p1) {
|
||||
case 'BREAK':
|
||||
return '<br/>';
|
||||
|
@ -331,8 +326,6 @@ Zotero.Utilities = {
|
|||
return p1;
|
||||
}
|
||||
});
|
||||
|
||||
return newString;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -78,7 +78,6 @@ const xpcomFilesLocal = [
|
|||
'data/tags',
|
||||
'db',
|
||||
'duplicates',
|
||||
'enstyle',
|
||||
'fulltext',
|
||||
'id',
|
||||
'integration',
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8c31f2f65be16563f4cd13d4598f9f697c7efdad
|
||||
Subproject commit 6a94601503b6e1c0e1b1e483a5b1d6a8610017e6
|
Loading…
Add table
Reference in a new issue