diff options
-rw-r--r-- | modules/filter/filter.module | 2 | ||||
-rw-r--r-- | modules/filter/filter.test | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/modules/filter/filter.module b/modules/filter/filter.module index ae07a6248..c0196c07a 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -897,10 +897,10 @@ function _filter_autop($text) { $chunk = preg_replace('!(</' . $block . '>)!', "$1\n\n", $chunk); // Space things out a little $chunk = preg_replace("/\n\n+/", "\n\n", $chunk); // take care of duplicates $chunk = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $chunk); // make paragraphs, including one at the end - $chunk = preg_replace('|<p>\s*</p>\n|', '', $chunk); // under certain strange conditions it could create a P of entirely whitespace $chunk = preg_replace("|<p>(<li.+?)</p>|", "$1", $chunk); // problem with nested lists $chunk = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $chunk); $chunk = str_replace('</blockquote></p>', '</p></blockquote>', $chunk); + $chunk = preg_replace('|<p>\s*</p>\n?|', '', $chunk); // under certain strange conditions it could create a P of entirely whitespace $chunk = preg_replace('!<p>\s*(</?' . $block . '[^>]*>)!', "$1", $chunk); $chunk = preg_replace('!(</?' . $block . '[^>]*>)\s*</p>!', "$1", $chunk); $chunk = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $chunk); // make line breaks diff --git a/modules/filter/filter.test b/modules/filter/filter.test index 3015bf91e..48444ebcb 100644 --- a/modules/filter/filter.test +++ b/modules/filter/filter.test @@ -200,7 +200,14 @@ class FilterTestCase extends DrupalWebTestCase { * Test the line break filter */ function testLineBreakFilter() { - + $f = _filter_autop('<p><div> </div></p>'); + $this->assertEqual(substr_count($f, '<p>'), substr_count($f, '</p>'), t('Make sure line breaking produces matching paragraph tags.')); + + $f = _filter_autop('<div><p> </p></div>'); + $this->assertEqual(substr_count($f, '<p>'), substr_count($f, '</p>'), t('Make sure line breaking produces matching paragraph tags.')); + + $f = _filter_autop('<blockquote><pre>aaa</pre></blockquote>'); + $this->assertEqual(substr_count($f, '<p>'), substr_count($f, '</p>'), t('Make sure line breaking produces matching paragraph tags.')); } /** |