Skip to content

Instantly share code, notes, and snippets.

@choonkeat
Created December 14, 2009 09:36
Show Gist options
  • Save choonkeat/255940 to your computer and use it in GitHub Desktop.
Save choonkeat/255940 to your computer and use it in GitHub Desktop.
/*
Minimum tinymce config for MS-Word sanity
Based on http://tinymce.moxiecode.com/examples/example_05.php
*/
tinyMCE.init({
setup : function(ed) {
ed.onPostProcess.add(function(ed, o) {
if (o.get) {
// cleaning up white spaces, remove unnecessary tags
// p, span, em should have no attributes (unlike img or a)
o.content = o.content.
replace(/\ /g, ' ').
replace(/\n\n*/gi, '').
replace(/<!--.+?-->|<(meta|link|style)[^>]*\/>/gi, '').
replace(/<(style)\b[^>]*>.*?<\/\1>|<(\w+)\b[^>]*>\s*?<\/\2>/gi, '').
replace(/<(p|span|em)\b[^>]+>/gi, '<$1>');
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment