Discovered a bug with the Serendipity NL2BR plugin. This plugin just uses PHP nl2br() function to replace all the newlines with BR tags. This causes problem when an excel table is pasted into the Serendipity WYSIWYG editor. The NL2BR inserted unnecessary BR tags at the end of the columns and rows. These additional BR tags appear as blank spaces above the table.
The fix is to modify file serendipity_event_nl2br.php. In particular to replace
$eventData[$element] = nl2br($eventData[$element]);
with
$eventData[$element] = preg_replace(":(</p>|[^>\s]|^)( *\r?\n):im","\\1<br />\\2",$eventData[$element]);
This regular expression basically replace the newline with BR tag only when of the following conditions is satified
- a </p> tag followed by a new line
- a character other than > followed by a newline
- a line containing only new line