Make WordPress Core

Opened 19 years ago

Closed 19 years ago

#488 closed defect (bug) (fixed)

convert linebreaks breaks pre-tag formattting

Reported by: bronski's profile bronski Owned by: matt's profile matt
Milestone: Priority: normal
Severity: minor Version: 1.5
Component: General Keywords:
Focuses: Cc:


When posting something within pre-tags that has empty lines those empty lines get padded with p-tags by the wpautop-filter. First, this breaks XHTML because it closes tags that haven't been opened and opens tags that never get closed, and second, after the p-tags font is not monospaced as it should be within pre-tags.

Change History (12)

#2 @bronski
19 years ago

The tags in "additional information" up there got swallowed, but is shows that monospaced font gets lost on the way... ;-)

Here's the example again:

line with textp</p>

<p>[p]line with text

edited on: 11-24-04 12:14

edited on: 11-24-04 12:15

#3 @bronski
19 years ago

There is a related post in the forums:

#4 @matt
19 years ago

Could you post the code to the wiki? It deals better with this:

#5 @matt
19 years ago

  • Patch set to No
  • Status changed from new to assigned

#6 @bronski
19 years ago

Sorry, I can't. Wiki doesn't seem to know me anymore...

#7 @2fargon
19 years ago

Login to the wiki using a name like CarThik (with two capitalized letters in it).

#9 @trevorturk
19 years ago

on a side note, using the CODE tags, or PRE doesn't do what I thought - i.e. doesn't just display the code. I've been using this:

#10 @anonymousbugger
19 years ago

These two lines added to wp-includes/functions-formatting.php seem to fix the problem:

function clean_pre($text) {

$text = str_replace('<br />', , $text);

+ $text = str_replace('<p>', "\n", $text);
+ $text = str_replace('</p>', , $text);

return $text;


#11 @bronski
19 years ago

bugger, first I did'nt log in and then I mess up the tags once again...

look at for the solution.

edited on: 12-20-04 10:58

#12 @matt
19 years ago

  • fixed_in_version set to 1.5
  • Owner changed from anonymous to matt
  • Resolution changed from 10 to 20
  • Status changed from assigned to closed

Added patch

Note: See TracTickets for help on using tickets.