Formatting: no <p> or <br> around <option> tags in both flavours of wpautop, make "selects" easier to read in the Text editor. Fixes #28217.

Built from https://develop.svn.wordpress.org/trunk@29315


git-svn-id: http://core.svn.wordpress.org/trunk@29096 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2014-07-28 19:44:18 +00:00
parent 1dab78032b
commit ad0f539621
3 changed files with 14 additions and 1 deletions

View File

@ -168,6 +168,11 @@ window.switchEditors = {
content = content.replace( new RegExp('\\s*</(' + blocklist2 + ')>\\s*', 'g' ), '</$1>\n' );
content = content.replace( /<li([^>]*)>/g, '\t<li$1>' );
if ( content.indexOf( '<option' ) !== -1 ) {
content = content.replace( /\s*<option/g, '\n<option' );
content = content.replace( /\s*<\/select>/g, '\n</select>' );
}
if ( content.indexOf( '<hr' ) !== -1 ) {
content = content.replace( /\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n' );
}
@ -244,6 +249,8 @@ window.switchEditors = {
pee = pee.replace( new RegExp( '(<(?:' + blocklist + ')(?: [^>]*)?>)', 'gi' ), '\n$1' );
pee = pee.replace( new RegExp( '(</(?:' + blocklist + ')>)', 'gi' ), '$1\n\n' );
pee = pee.replace( /<hr( [^>]*)?>/gi, '<hr$1>\n\n' ); // hr is self closing block element
pee = pee.replace( /\s<option/gi, '<option' ); // No <p> or <br> around <option>
pee = pee.replace( /<\/option>\s/gi, '</option>' );
pee = pee.replace( /\r\n|\r/g, '\n' );
pee = pee.replace( /\n\s*\n+/g, '\n\n' );
pee = pee.replace( /([\s\S]+?)\n\n/g, '<p>$1</p>\n' );

File diff suppressed because one or more lines are too long

View File

@ -392,6 +392,12 @@ function wpautop($pee, $br = true) {
$pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
$pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
if ( strpos( $pee, '<option' ) !== false ) {
// no P/BR around option
$pee = preg_replace( '|\s<option|', '<option', $pee );
$pee = preg_replace( '|</option>\s|', '</option>', $pee );
}
if ( strpos( $pee, '</object>' ) !== false ) {
// no P/BR around param and embed
$pee = preg_replace( '|(<object[^>]*>)\s*|', '$1', $pee );