Fix creating of extra <br /> tags in both PHP and JS variants of wpautop(). Add PHP tests to catch similar problems in the future.
Props valendesigns, azaozz. Fixes #33377. Built from https://develop.svn.wordpress.org/trunk@33624 git-svn-id: http://core.svn.wordpress.org/trunk@33591 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -272,7 +272,13 @@
|
||||
text = text.replace( /<\/blockquote>\s*<\/p>/gi, '</p></blockquote>');
|
||||
text = text.replace( new RegExp( '<p>\\s*(</?(?:' + blocklist + ')(?: [^>]*)?>)', 'gi' ), '$1' );
|
||||
text = text.replace( new RegExp( '(</?(?:' + blocklist + ')(?: [^>]*)?>)\\s*</p>', 'gi' ), '$1' );
|
||||
text = text.replace( /\s*\n/gi, '<br />\n');
|
||||
|
||||
// Remove redundant spaces and line breaks after existing <br /> tags
|
||||
text = text.replace( /(<br[^>]*>)\s*\n/gi, '$1' );
|
||||
|
||||
// Create <br /> from the remaining line breaks
|
||||
text = text.replace( /\s*\n/g, '<br />\n');
|
||||
|
||||
text = text.replace( new RegExp( '(</?(?:' + blocklist + ')[^>]*>)\\s*<br />', 'gi' ), '$1' );
|
||||
text = text.replace( /<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)/gi, '$1' );
|
||||
text = text.replace( /(?:<p>|<br ?\/?>)*\s*\[caption([^\[]+)\[\/caption\]\s*(?:<\/p>|<br ?\/?>)*/gi, '[caption$1[/caption]' );
|
||||
|
||||
Reference in New Issue
Block a user