Getting rid of extra BR lines in WordPress MU

August 13th, 2008 by Dan York

Today we had a wee bit of fun with HTML tables… Jeremy, a member of our support team, published a post on our Voxeo Developer’s Corner blog that had an HTML <table> in it. Now it turned out that this was the first time in the 10 months that we’ve had this blog site up that anyone has used a <table> tag… and WordPress MU wasn’t terribly happy about it! What happened is that WPMU inserted a <br/> tag at the end of every line of HTML in the table. Annoyingly, the BR tags were inserted outside of the <TD> tags with the result being that a browser bizarrely interpreted the BRs to be a bunch of blank lines before the table.

Naturally I blamed Rick’s CSS file for lacking some table handling and he of course blamed all my plugins for messing up the formatting. A Google search helped us find out that the answer was neither but instead was actually WordPress itself.

This web page started out with the key heading “Disabling WordPress’ slap-happy approach to <br /> tags” and provided the answer. That web page is for WordPress 2.0.2 and we’re now running the equivalent of WP 2.5, so the file is no longer functions-formatting.php but instead simply formatting.php. As before it lives in <WPMU>/wp-includes.

Inside the file starting at line 62 was this:

function wpautop($pee, $br = 1) {
        $pee = $pee . "\n"; // just to make things a little easier, pad the end
        $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);

One simple change of “$br = 1″ to “$br = 0″:

function wpautop($pee, $br = 0) {
        $pee = $pee . "\n"; // just to make things a little easier, pad the end
        $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);

and… ta da… the BR tags went away and the table no longer had this mass of white space before it.

Fun, fun, fun…. (well, not really)

Technorati Tags:
, ,

Tags: , ,

One Response to “Getting rid of extra BR lines in WordPress MU”

  1. Behind The Blog » Blog Archive » Adding space above the Seesmic plugin video comment link Says:

    [...] Behind The Blog A blog about a blog (site)… a view inside a WordPress MU installation « Getting rid of extra BR lines in WordPress MU [...]

Leave a Reply

Please note: By submitting a comment you agree to comply with our Comment Policy. We welcome all comments, positive or negative, but do reserve the right to remove all or part of blog comments that do not comply with our policy.