Formatting: fix wpautop()
to stop adding paragraph tags around <figcaption>
.
Fixes #39307 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@39912 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f8cc0fda44
commit
14e5a08f5c
@ -167,7 +167,7 @@
|
|||||||
* @return {string} The content with stripped paragraph tags.
|
* @return {string} The content with stripped paragraph tags.
|
||||||
*/
|
*/
|
||||||
function removep( html ) {
|
function removep( html ) {
|
||||||
var blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset',
|
var blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure',
|
||||||
blocklist1 = blocklist + '|div|p',
|
blocklist1 = blocklist + '|div|p',
|
||||||
blocklist2 = blocklist + '|pre',
|
blocklist2 = blocklist + '|pre',
|
||||||
preserve_linebreaks = false,
|
preserve_linebreaks = false,
|
||||||
@ -331,6 +331,11 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( text.indexOf( '<figcaption' ) !== -1 ) {
|
||||||
|
text = text.replace( /\s*(<figcaption[^>]*>)/g, '$1' );
|
||||||
|
text = text.replace( /<\/figcaption>\s*/g, '</figcaption>' );
|
||||||
|
}
|
||||||
|
|
||||||
// Keep <br> tags inside captions.
|
// Keep <br> tags inside captions.
|
||||||
if ( text.indexOf( '[caption' ) !== -1 ) {
|
if ( text.indexOf( '[caption' ) !== -1 ) {
|
||||||
preserve_br = true;
|
preserve_br = true;
|
||||||
|
@ -506,6 +506,12 @@ function wpautop( $pee, $br = true ) {
|
|||||||
$pee = preg_replace( '%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $pee );
|
$pee = preg_replace( '%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $pee );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Collapse line breaks before and after <figcaption> elements.
|
||||||
|
if ( strpos( $pee, '<figcaption' ) !== false ) {
|
||||||
|
$pee = preg_replace( '|\s*(<figcaption[^>]*>)|', '$1', $pee );
|
||||||
|
$pee = preg_replace( '|</figcaption>\s*|', '</figcaption>', $pee );
|
||||||
|
}
|
||||||
|
|
||||||
// Remove more than two contiguous line breaks.
|
// Remove more than two contiguous line breaks.
|
||||||
$pee = preg_replace("/\n\n+/", "\n\n", $pee);
|
$pee = preg_replace("/\n\n+/", "\n\n", $pee);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user