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:
Andrew Ozz
2015-08-17 17:36:24 +00:00
parent 50e42e8a07
commit 2de7757124
4 changed files with 13 additions and 4 deletions

View File

@@ -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]' );