www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit e638190ca99da8ad43466aaef34a9a497272d7a1
parent 43025f971d39ce29bb9762ffb74400554fa545f8
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 18 Dec 2009 10:21:19 +0000

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


Diffstat:
Mchrome/content/zotero/bindings/styled-textbox.xml | 26++++++++++++++++++++++++++
1 file changed, 26 insertions(+), 0 deletions(-)

diff --git a/chrome/content/zotero/bindings/styled-textbox.xml b/chrome/content/zotero/bindings/styled-textbox.xml @@ -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); }