Anyway...
With help from some members on the SitePoint forums, I've modified the serendipity_event_plugin_nl2br to work with HTML textarea, pre, and the BBCode GeSHi modifiers so that those ugly <br /> tags aren't added when they aren't wanted.
Here's what I did:
- Open up plugins\serendipity_event_nl2br\serendipity_event_nl2br.php in your serendipity folder
- add two new functions (within the class, but order of where they go is unimportant, I placed them before the event_hook function) as shown below:
Code: Select all
function isolate($src, $regexp = NULL)
{
if($regexp) return preg_replace_callback($regexp, array($this, 'isolate'), $src);
global $_buf;
$_buf[] = $src[0];
return "\001" . (count($_buf) - 1);
}
function restore($text)
{
global $_buf;
return preg_replace('~\001(\d+)~e', '$_buf[$1]', $text);
}
Code: Select all
$eventData[$element] = $this->isolate($eventData[$element], '~[<\[](textarea|pre|geshi).*?[>\]].*?[<\[]/\1[>\]]~si');
$eventData[$element] = nl2br($eventData[$element]);
$eventData[$element] = $this->restore($eventData[$element]);
This modified version should not effect anyone using the rich text editor, but will help those trying to use GeSHi or other code-posting methods. I would strongly suggest applying this to the current nl2br plugin, and/or replacing it and giving it a different name (nl2br_enhanced).