Editor: When stripping paragraph tags, and there is a <br> at the beginning or the end, merge them and keep the paragraph, not the <br>.
Props rellect. Fixes #37066. git-svn-id: https://develop.svn.wordpress.org/trunk@40787 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ee2ffd6ba2
commit
eb5320247a
|
@ -224,8 +224,14 @@ window.wp = window.wp || {};
|
||||||
// Normalize white space chars and remove multiple line breaks.
|
// Normalize white space chars and remove multiple line breaks.
|
||||||
html = html.replace( /\n[\s\u00a0]+\n/g, '\n\n' );
|
html = html.replace( /\n[\s\u00a0]+\n/g, '\n\n' );
|
||||||
|
|
||||||
// Rrplace <br> tags with a line break.
|
// Replace <br> tags with line breaks.
|
||||||
html = html.replace( /\s*<br ?\/?>\s*/gi, '\n' );
|
html = html.replace( /(\s*)<br ?\/?>\s*/gi, function( match, space ) {
|
||||||
|
if ( space && space.indexOf( '\n' ) !== -1 ) {
|
||||||
|
return '\n\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '\n';
|
||||||
|
});
|
||||||
|
|
||||||
// Fix line breaks around <div>.
|
// Fix line breaks around <div>.
|
||||||
html = html.replace( /\s*<div/g, '\n<div' );
|
html = html.replace( /\s*<div/g, '\n<div' );
|
||||||
|
|
Loading…
Reference in New Issue