Ticket #771: scaps-rev1.patch

File scaps-rev1.patch, 1.5 KB (added by fbennett, 7 years ago)

small caps patch (revised)

  • chrome/content/zotero/bindings/styled-textbox.xml

     
    163163                                                for(var needle in this._rtfMap) { 
    164164                                                        output = output.replace(needle, this._rtfMap[needle], "g");  
    165165                                                } 
    166                                                  
     166                                                while (output.match(/<span[^>]*small-caps[^>]*>/)){ 
     167                                                        var l = output.split(/<span[^>]*small-caps[^>]*>/); 
     168                                                        for (var pos=1; pos<l.length; pos+=1){ 
     169                                                                var spanmatch = l[pos].match(/<span[^>]*>/g); 
     170                                                                var lx = l[pos].split("</span>"); 
     171                                                                if (spanmatch){ 
     172                                                                        var mymid = lx.slice(0,spanmatch.length).join("</span>"); 
     173                                                                        var myend = lx.slice(spanmatch.length).join("\\scaps0 "); 
     174                                                                        l[pos] = mymid + "\\scaps0 " + myend; 
     175                                                                } else { 
     176                                                                        l[pos] = lx.join("\\scaps0 "); 
     177                                                                } 
     178                                                        } 
     179                                                        output = l.join("\\scaps "); 
     180                                                } 
    167181                                                output = output.replace("<p>", "", "g"); 
    168182                                                output = output.replace("</p>", "\\par ", "g"); 
    169183                                                output = output.replace(/<\/?div[^>]*>/g, ""); 
     
    236250                                                                html = html.replace(this._rtfMap[needle], needle, "g"); 
    237251                                                        } 
    238252                                                } 
     253                                                html = html.replace("\\scaps ", "<span style=\"font-variant:small-caps\">", "g"); 
     254                                                html = html.replace("\\scaps0 ", "</span>", "g"); 
    239255                                                html = '<div style="'+bodyStyle+'"><p>'+html.replace("\par ", "</p><p>")+"</p></div>"; 
    240256                                                Zotero.debug("setting content to "+html); 
    241257                                        }