Fix issue reported at http://forums.zotero.org/discussion/26922/
In HTML, <span/> counts as <span>, not as <span></span>. We now use the HTML parser and serializer rather than the XML serializer to create empty span tags. Separate fix coming for 3.0 branch
This commit is contained in:
parent
4c58f248d1
commit
69ce6b7d1a
1 changed files with 86 additions and 96 deletions
|
@ -141,7 +141,7 @@ Zotero.Cite = {
|
||||||
if(!co) continue;
|
if(!co) continue;
|
||||||
output.push(' <span class="Z3988" title="'+
|
output.push(' <span class="Z3988" title="'+
|
||||||
co.replace("&", "&", "g").replace("<", "<", "g").replace(">", ">", "g")+
|
co.replace("&", "&", "g").replace("<", "<", "g").replace(">", ">", "g")+
|
||||||
'"/>\n');
|
'"></span>\n');
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
Zotero.logError(e);
|
Zotero.logError(e);
|
||||||
}
|
}
|
||||||
|
@ -173,10 +173,9 @@ Zotero.Cite = {
|
||||||
if(lineSpacing == NaN) throw "Invalid linespacing";
|
if(lineSpacing == NaN) throw "Invalid linespacing";
|
||||||
|
|
||||||
var str;
|
var str;
|
||||||
try {
|
|
||||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||||
.createInstance(Components.interfaces.nsIDOMParser),
|
.createInstance(Components.interfaces.nsIDOMParser),
|
||||||
doc = parser.parseFromString(html, "application/xml");
|
doc = parser.parseFromString(html, "text/html");
|
||||||
|
|
||||||
var leftMarginDivs = Zotero.Utilities.xpath(doc, '//div[@class="csl-left-margin"]'),
|
var leftMarginDivs = Zotero.Utilities.xpath(doc, '//div[@class="csl-left-margin"]'),
|
||||||
multiField = !!leftMarginDivs.length,
|
multiField = !!leftMarginDivs.length,
|
||||||
|
@ -251,7 +250,7 @@ Zotero.Cite = {
|
||||||
divStyle = "margin: 0 .4em 0 " + (secondFieldAlign ? maxOffset + rightPadding : "0") + "em;";
|
divStyle = "margin: 0 .4em 0 " + (secondFieldAlign ? maxOffset + rightPadding : "0") + "em;";
|
||||||
|
|
||||||
if (hangingIndent) {
|
if (hangingIndent) {
|
||||||
divSstyle += "padding-left: " + hangingIndent + "em; text-indent:-" + hangingIndent + "em;";
|
divStyle += "padding-left: " + hangingIndent + "em; text-indent:-" + hangingIndent + "em;";
|
||||||
}
|
}
|
||||||
|
|
||||||
div.setAttribute("style", divStyle);
|
div.setAttribute("style", divStyle);
|
||||||
|
@ -262,16 +261,7 @@ Zotero.Cite = {
|
||||||
div.setAttribute("style", "margin: .5em 0 0 2em; padding: 0 0 .2em .5em; border-left: 5px solid #ccc;");
|
div.setAttribute("style", "margin: .5em 0 0 2em; padding: 0 0 .2em .5em; border-left: 5px solid #ccc;");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Zotero.debug(xml);
|
return doc.documentElement.outerHTML;
|
||||||
var s = Components.classes["@mozilla.org/xmlextras/xmlserializer;1"]
|
|
||||||
.createInstance(Components.interfaces.nsIDOMSerializer);
|
|
||||||
str = s.serializeToString(doc);
|
|
||||||
} finally {
|
|
||||||
XML.prettyPrinting = true;
|
|
||||||
XML.ignoreWhitespace = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return str;
|
|
||||||
} else if(format == "text") {
|
} else if(format == "text") {
|
||||||
return bib[0].bibstart+bib[1].join("")+bib[0].bibend;
|
return bib[0].bibstart+bib[1].join("")+bib[0].bibend;
|
||||||
} else if(format == "rtf") {
|
} else if(format == "rtf") {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue