Ticket #771: scaps.patch

File scaps.patch, 1.6 KB (added by fbennett, 7 years ago)

Patch to preserve small caps in style editor

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

     
    161161                                        if(this._format == "Integration" || this._format == "RTF") { 
    162162                                                // do appropriate replacement operations 
    163163                                                for(var needle in this._rtfMap) { 
    164                                                         output = output.replace(needle, this._rtfMap[needle], "g");  
     164                                                    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                                                    var m = l[1].match(/<span[^>]*>/g); 
     169                                                        if (m){ 
     170                                                            var n = m.length; 
     171                                                                var x = l[1].split("</span>"); 
     172                                                                var mymiddle = l[1].slice(0,n).join("</span>"); 
     173                                                                var myend = l[1].slice(n).join("</span>"); 
     174                                                                l[1] = mymiddle + "\\scaps0 " + myend; 
     175                                                        } 
     176                                                        output = l.join("\\scaps "); 
     177                        } 
    167178                                                output = output.replace("<p>", "", "g"); 
    168179                                                output = output.replace("</p>", "\\par ", "g"); 
    169180                                                output = output.replace(/<\/?div[^>]*>/g, ""); 
     
    236247                                                                html = html.replace(this._rtfMap[needle], needle, "g"); 
    237248                                                        } 
    238249                                                } 
     250                                                html = html.replace("\\scaps ", "<span style=\"font-variant:small-caps\">", "g"); 
     251                                                html = html.replace("\\scaps0 ", "</span>", "g"); 
    239252                                                html = '<div style="'+bodyStyle+'"><p>'+html.replace("\par ", "</p><p>")+"</p></div>"; 
    240253                                                Zotero.debug("setting content to "+html); 
    241254                                        }