Make WordPress Core

Opened 5 years ago

Closed 19 months ago

#15367 closed defect (bug) (fixed)

WordPress strips multiple line breaks inside of <pre> tags

Reported by: Viper007Bond Owned by: garyc40
Milestone: 3.4 Priority: normal
Severity: normal Version: 3.1
Component: Formatting Keywords: wpautop needs-unit-tests
Focuses: Cc:


Write a post:




You end up with this:




Probably related to wpautop() I imagine.

Attachments (1)

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

Download all attachments as: .zip

Change History (20)

comment:1 @Viper007Bond5 years ago

  • Keywords needs-patch added

comment:2 @azaozz5 years ago

  • 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: @Viper007Bond5 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 @azaozz5 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.

comment:5 @Viper007Bond5 years ago

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.

comment:6 @Viper007Bond5 years ago

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

comment:7 @Viper007Bond5 years ago

I also need to learn to spell apparently...

comment:8 @westi5 years ago

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

comment:9 @nacin5 years ago

  • Keywords 3.2-early wpautop added
  • Milestone changed from Awaiting Review to Future Release

comment:10 @garyc405 years ago

  • Owner set to garyc40
  • Status changed from reopened to assigned

@TomAuger4 years ago

Modified wpautop in formatting.php

comment:12 @TomAuger4 years ago

  • 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.

comment:13 @SergeyBiryukov4 years ago

  • Keywords has-patch added; needs-patch removed

Closed #19666 as a duplicate.

comment:14 @MikeHansenMe3 years ago

  • Cc MikeHansenMe added
  • Keywords needs-refresh added

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

comment:15 @MikeHansenMe3 years ago

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.

comment:16 @nacin21 months ago

  • Keywords needs-unit-tests added

I can't seem to reproduce this. This needs a unit test, then maybe we can figure out exactly what (PHP/JS/TinyMCE) needs changing.

comment:17 @azaozz21 months ago

This was fixed (together with another <pre> issue) in [20307], see #19855. The approach is similar to the patch here.

comment:18 @miqrogroove19 months ago

  • Keywords 3.2-early needs-testing has-patch needs-refresh removed

comment:19 @SergeyBiryukov19 months ago

  • Milestone changed from Future Release to 3.4
  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.