mirror of
https://github.com/zotero/zotero.git
synced 2026-10-10 03:28:10 +00:00
Fixes #771, small caps and editor
Patch from Frank (with a few stylistic tweaks) to preserve small caps in citation editor -- since we now use TinyMCE rather than Midas, we could actually include a button for small caps, but this is probably sufficient
This commit is contained in:
parent
43025f971d
commit
e638190ca9
1 changed files with 26 additions and 0 deletions
|
|
@ -164,6 +164,28 @@
|
|||
output = output.replace(needle, this._rtfMap[needle], "g");
|
||||
}
|
||||
|
||||
// Preserve small caps
|
||||
var l = output.split(/(<\/?span[^>]*>)/);
|
||||
var current_level = 0;
|
||||
var tag_level = [];
|
||||
for (var pos=1; pos<l.length; pos+=2) {
|
||||
var tag = l[pos];
|
||||
if (tag[1] == "/") {
|
||||
current_level--;
|
||||
if (current_level == tag_level[tag_level.length-1]) {
|
||||
tag_level.pop();
|
||||
l[pos] = "\\scaps0 ";
|
||||
}
|
||||
} else {
|
||||
if (l[pos].match(/small-caps/)) {
|
||||
l[pos] = "\\scaps ";
|
||||
tag_level.push(current_level);
|
||||
}
|
||||
current_level++;
|
||||
};
|
||||
};
|
||||
output = l.join("");
|
||||
|
||||
output = output.replace("<p>", "", "g");
|
||||
output = output.replace("</p>", "\\par ", "g");
|
||||
output = output.replace(/<\/?div[^>]*>/g, "");
|
||||
|
|
@ -236,6 +258,10 @@
|
|||
html = html.replace(this._rtfMap[needle], needle, "g");
|
||||
}
|
||||
}
|
||||
|
||||
html = html.replace("\\scaps ", "<span style=\"font-variant:small-caps\">", "g");
|
||||
html = html.replace("\\scaps0 ", "</span>", "g");
|
||||
|
||||
html = '<div style="'+bodyStyle+'"><p>'+html.replace("\par ", "</p><p>")+"</p></div>";
|
||||
Zotero.debug("setting content to "+html);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue