Make WordPress Core

Opened 20 years ago

Closed 20 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:

Description

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
20 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:

<pre>[pre]
line with textp</p>

<p>[p]line with text
pre</pre>

edited on: 11-24-04 12:14

edited on: 11-24-04 12:15

#3 @bronski
20 years ago

There is a related post in the forums: http://wordpress.org/support/3/10535

#4 @matt
20 years ago

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

http://wiki.wordpress.org/?pagename=autop-bugs

#5 @matt
20 years ago

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

#6 @bronski
20 years ago

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

#7 @2fargon
20 years ago

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

#9 @trevorturk
20 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:
http://resources.wordpress.org/tools/encode/

#10 @anonymousbugger
20 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
20 years ago

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

look at http://wiki.wordpress.org/?pagename=autop-bugs for the solution.

edited on: 12-20-04 10:58

#12 @matt
20 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.