Opened 3 years ago

Last modified 8 months ago

#15367 assigned defect (bug)

WordPress strips multiple line breaks inside of <pre> tags

Reported by: Viper007Bond Owned by: garyc40
Priority: normal Milestone: Future Release
Component: Formatting Version: 3.1
Severity: normal Keywords: 3.2-early wpautop needs-testing has-patch needs-refresh
Cc: MikeHansenMe

Description

Write a post:

<pre>
This


is




a
test.
</pre>

You end up with this:

<pre>
This

is

a
test.
</pre>

Probably related to wpautop() I imagine.

Attachments (1)

15367_formatting_wpautop.patch (2.0 KB) - added by TomAuger 19 months ago.
Modified wpautop in formatting.php

Download all attachments as: .zip

Change History (16)

  • Keywords needs-patch added
  • Resolution set to fixed
  • Status changed from new to closed

(In [16394]) Remove invalid parent paragraph when pasting in the visual editor or switching visual to HTML and back, keep multiple empty lines in a <pre> tag, fixes #15095 fixes #15367

comment:3 follow-up: ↓ 4   Viper007Bond3 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

This isn't a TinyMCE issue, it's an output filter issue.

comment:4 in reply to: ↑ 3   azaozz3 years ago

Replying to Viper007Bond:
The same was happening when switching editors, perhaps we can apply the changes from the JS version of wpautop to the php one.

No I mean this isn't an editor issue. If I write the above example in the HTML editor, it stays exactly like that. I save the post, still correct. When I view it on the front end however, the extra line breaks are stripped out.

Whoops, I need to learn to read. Yes, we need to apply the code to the PHP-based `wpautp()~ too.

I also need to learn to spell apparently...

Nah you can spell apparently fairly well it's the other words you should practice ;-)

  • Keywords 3.2-early wpautop added
  • Milestone changed from Awaiting Review to Future Release
  • Owner set to garyc40
  • Status changed from reopened to assigned

Modified wpautop in formatting.php

  • Keywords needs-testing added

My approach was to preserve all content inside <pre> tags from most of the substitution that occurs on the rest of the text. As a result, the call to clean_pre() is no longer necessary.

  • Keywords has-patch added; needs-patch removed

Closed #19666 as a duplicate.

  • Cc MikeHansenMe added
  • Keywords needs-refresh added

This problem still exists but the patch would not apply. Needs Refresh.

In addition to my last comment the problem still exist when switching between Visual and Text mode. If you paste the example in text mode and click publish then reload the page it remains as it should. It seems a similar fix is needed for the js.

Note: See TracTickets for help on using tickets.