mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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:
parent
1dab78032b
commit
ad0f539621
@ -168,6 +168,11 @@ window.switchEditors = {
|
|||||||
content = content.replace( new RegExp('\\s*</(' + blocklist2 + ')>\\s*', 'g' ), '</$1>\n' );
|
content = content.replace( new RegExp('\\s*</(' + blocklist2 + ')>\\s*', 'g' ), '</$1>\n' );
|
||||||
content = content.replace( /<li([^>]*)>/g, '\t<li$1>' );
|
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 ) {
|
if ( content.indexOf( '<hr' ) !== -1 ) {
|
||||||
content = content.replace( /\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n' );
|
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' ), '\n$1' );
|
||||||
pee = pee.replace( new RegExp( '(</(?:' + blocklist + ')>)', 'gi' ), '$1\n\n' );
|
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( /<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( /\r\n|\r/g, '\n' );
|
||||||
pee = pee.replace( /\n\s*\n+/g, '\n\n' );
|
pee = pee.replace( /\n\s*\n+/g, '\n\n' );
|
||||||
pee = pee.replace( /([\s\S]+?)\n\n/g, '<p>$1</p>\n' );
|
pee = pee.replace( /([\s\S]+?)\n\n/g, '<p>$1</p>\n' );
|
||||||
|
2
wp-admin/js/editor.min.js
vendored
2
wp-admin/js/editor.min.js
vendored
File diff suppressed because one or more lines are too long
@ -392,6 +392,12 @@ function wpautop($pee, $br = true) {
|
|||||||
$pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
|
$pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
|
||||||
$pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
|
$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 ) {
|
if ( strpos( $pee, '</object>' ) !== false ) {
|
||||||
// no P/BR around param and embed
|
// no P/BR around param and embed
|
||||||
$pee = preg_replace( '|(<object[^>]*>)\s*|', '$1', $pee );
|
$pee = preg_replace( '|(<object[^>]*>)\s*|', '$1', $pee );
|
||||||
|
Loading…
Reference in New Issue
Block a user