var view = ko.views.manager.currentView; var tmpFileSvc = Components.classes["@activestate.com/koFileService;1"] .getService(Components.interfaces.koIFileService) fname = tmpFileSvc.makeTempName(".html"); var lang = view.document.languageObj; var forceColor = true; var selectionOnly = view.selection != ""; var schemeService = Components.classes['@activestate.com/koScintillaSchemeService;1'].getService(); schemeService.convertToHTMLFile(view.scimoz, view.document.displayPath, view.document.language, lang.styleBits, view.document.encoding.python_encoding_name, fname, selectionOnly, forceColor); var file = Components.classes["@activestate.com/koFileEx;1"] .createInstance(Components.interfaces.koIFileEx) file.URI = ko.uriparse.localPathToURI(fname); file.open('rb'); var str = file.readfile(); file.close(); str = str.replace(/\n|\r/g, ""); var m = str.match(/\s*[a-zA-Z0-9._-]*\s*{.*?}/g); var styles = {}; for (var i in m) { var selector = m[i].match(/\s*([a-zA-Z0-9._-]*)\s*{(.*?)}/); if (selector && /^span\./.test(selector)) { styles[selector[1].substring("span.".length)] = selector[2].replace(/(^\s*|\s*$)/g, ""); } } m = str.match(/(/); var result = m[1] for (i in styles) { var style = styles[i]; result = result.replace(new RegExp('', "g"), ''); } result = result.replace(/ /g, ' ') // OpenOffice Writer ignores nbsp //.replace(/
/g, ''); result = '
' + result + '
'; xtk.include("clipboard"); transferable = xtk.clipboard.addTextDataFlavor("text/html", result); xtk.clipboard.copyFromTransferable(transferable);