/g, ""], - //[/<\/p>(?!\s*$)/g, "\\par{}"], - [/<\/?div[^>]*>/g, ""], - [/[\x7F-\uFFFF]/g, function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+"{}"}] + [/<\/?div[^>]*>/g, ""] ]; + // Atomic units, RTF -> HTML (cleanup) this._rtfHTMLmap = [ - // Atomic units, RTF -> HTML (cleanup) [/\\uc0\{?\\u([0-9]+)\}?(?:{}| )?/g, function(wholeStr, aCode) { return String.fromCharCode(aCode) }], [/\\tab(?:\{\}| )/g, ' '], [/(?:\\par{}|\\\r?\n)/g, "
"] @@ -339,14 +346,13 @@ } this.htmlToRTF = function(txt) { - // Catch this one before is clobbered by unescape - txt = txt.replace(/ <\/span>/g, "\\tab{}"); - txt = Zotero.Utilities.unescapeHTML(txt); + txt = this.convert("htmlRTF", txt); for (var i=0,ilen=this._htmlRTFmap.length; i < ilen; i++) { var entry = this._htmlRTFmap[i]; txt = txt.replace(entry[0], entry[1]); } - txt = this.convert("htmlRTF", txt); + txt = Zotero.Utilities.unescapeHTML(txt); + txt = txt.replace(/[\x7F-\uFFFF]/g, function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+"{}"}); return txt.trim(); }