Sun 14 May 2006
As a big fan for PRE tags, I use it a lot in blog. Unfortunately, the WYSIWYG editor deployed in this blog, EditMonkey 2.5 does not like PRE so much: once stored in database, all the new line in the PREs are missing, which is quite annoying. Thus I prepared a fix here.
Only modifing one file is enough to fix this, here is the patch:
--- editormonkey.php.orig 2006-04-21 01:22:40.000000000 +0000
+++ editormonkey.php 2006-05-14 23:02:33.000000000 +0000
@@ -112,6 +112,8 @@
add_action('admin_head',array('editormonkey', 'insert_interface'));
add_action('edit_form_advanced',array('editormonkey', 'load_interface'));
add_action('edit_page_form',array('editormonkey', 'load_interface'));
+ add_filter('content_save_pre',array('editormonkey', 'filter_content'));
+
add_action('simple_edit_form',array('editormonkey', 'load_interface'));
// Add actions to the comment form
@@ -165,7 +167,30 @@
}
}
-
+ function filter_content($content) {
+ if(preg_match( "#<pre.*>#imU", $content) > 0)
+ {
+ $splices = preg_split("#(<\/?pre.*>)#iU", $content, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
+ $content = '';
+ $inside_pre = false;
+ foreach($splices as $s)
+ {
+ if(substr(strtolower($s),0,4) == '<pre')
+ {
+ $inside_pre = true;
+ }else if (substr(strtolower($s),0,5) == '</pre')
+ {
+ $inside_pre = false;
+ }else if($inside_pre)
+ {
+ $content .= htmlspecialchars(preg_replace("#<\s*br\s*\/?>#i", "\n", $s));
+ continue;
+ }
+ $content .= $s;
+ }
+ }
+ return $content;
+ }
/**
Creates a personal dictionary, 0=plugin/global dictionary
*/
RSS feed for comments on this post. TrackBack this post