Opened 10 years ago
Closed 10 years ago
#33377 closed defect (bug) (fixed)
Wpautop may create extra <br> tags
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.3 | Priority: | high |
Severity: | normal | Version: | 4.3 |
Component: | Formatting | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
Caused by removing the <br>
tag normalization from convert_chars()
and by the fact that wpautop() uses negative look behind to check for <br />
followed by a line break.
This is also broken in the JS wpautop.
Attachments (3)
Change History (17)
#3
@
10 years ago
- Keywords has-patch added; needs-patch removed
In 33377.patch:
- PHP wpautop: replace
<br>
and<br/>
with<br />
before converting line breaks. - JS wpautop: remove spaces and line breaks after existing
<br>
before converting line breaks.
#5
@
10 years ago
Would it be easier to normalize BRs as newlines? If that's done before newline normalization, it might work.
#6
@
10 years ago
493 // Change multiple <br>s into two line breaks, which will turn into paragraphs.
Needs tests for that.
#8
@
10 years ago
33377.2.diff adds a second test and changes the regex pattern on line 493 to account for oddly formatted break tags when making the conversion to paragraphs.
#10
@
10 years ago
33377.3.diff looks good for now.
Eventually in PHP we should do something similar to the JS -- remove line breaks after any <br>, replace remaining line breaks with <br>, add line breaks after all <br> to make it prettier.
$pee = preg_replace( '|(<br[^>]*>)\s*\n|i', '$1', $pee ); $pee = preg_replace( '|\s*\n|', '<br />', $pee ); $pee = preg_replace( '|(<br[^>]*>)|i', "$1\n", $pee );
This changes the behaviour so a bit reluctant to do it now, so close to release.
The best way to restore the behaviour is to normalize the
<br>
. This has to be added to the JS wpautop as now we use it on loading the content in TinyMCE.