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

git-svn-id: https://develop.svn.wordpress.org/trunk@29315 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-07-28 19:43:06 +00:00
parent 70a6b6390c
commit 5fa36977a0
2 changed files with 13 additions and 0 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' );

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 );