mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-05 02:10:45 +01:00
autop fixes from skeltoac. fixes #2022
git-svn-id: http://svn.automattic.com/wordpress/trunk@3273 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9d4c41b823
commit
3d55d1e28c
@ -59,12 +59,12 @@ function wpautop($pee, $br = 1) {
|
|||||||
$pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
|
$pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
|
||||||
// Space things out a little
|
// Space things out a little
|
||||||
$pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "\n$1", $pee);
|
$pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "\n$1", $pee);
|
||||||
$pee = preg_replace('!(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])>)!', "$1\n", $pee);
|
$pee = preg_replace('!(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])>)!', "$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
|
||||||
$pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
|
$pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
|
||||||
$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
|
$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
|
||||||
$pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
|
$pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
|
||||||
$pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
|
$pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
|
||||||
$pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
|
$pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
|
||||||
$pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
|
$pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
|
||||||
$pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
|
$pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
|
||||||
|
@ -266,7 +266,7 @@ function wp_save_callback(el, content, body) {
|
|||||||
content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
|
content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
|
||||||
|
|
||||||
// Fix some block element newline issues
|
// Fix some block element newline issues
|
||||||
var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\d|pre';
|
var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre';
|
||||||
content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
|
content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
|
||||||
content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
|
content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
|
||||||
content = content.replace(new RegExp('<li>', 'g'), '\t<li>');
|
content = content.replace(new RegExp('<li>', 'g'), '\t<li>');
|
||||||
|
Loading…
Reference in New Issue
Block a user