diff options
-rw-r--r-- | modules/node.module | 20 | ||||
-rw-r--r-- | modules/node/node.module | 20 |
2 files changed, 34 insertions, 6 deletions
diff --git a/modules/node.module b/modules/node.module index a607fd788..60c9af813 100644 --- a/modules/node.module +++ b/modules/node.module @@ -334,8 +334,15 @@ function node_filter_link($text) { } function node_filter_line($text) { + /* - ** If HTML mark-up is being used, strip regular mark-up: + ** This "line break filter" will try to get the line breaks right + ** regardless of the user's input. Its goal aspires a consistent + ** mark-up and use of line breaks and paragraphs. + */ + + /* + ** If HTML mark-up is being used, strip regular line breaks: */ if (strstr($text, "<br />") || strstr($text, "<p>")) { @@ -349,10 +356,10 @@ function node_filter_line($text) { $text = eregi_replace("<br>", "\n", $text); $text = eregi_replace("<br />", "\n", $text); $text = eregi_replace("<p>", "\n", $text); - $text = eregi_replace("<br />", "\n", $text); + $text = eregi_replace("<p />", "\n", $text); /* - ** Replace "\r\n" by "\n": + ** Replace '\r\n' by '\n': */ $text = ereg_replace("\r\n", "\n", $text); @@ -365,6 +372,13 @@ function node_filter_line($text) { $text = ereg_replace("\n\n\n", "\n\n", $text); } + /* + ** Replace some common "artifacts": + */ + + $list = "blockquote|li|ol|ul|table|th|td|tr|pre"; + $text = preg_replace(array("/\n\s*<([\/])($list)/", "/($list)>\s*\n/"), array("<$1$2", "$1>"), $text); + return trim($text); } diff --git a/modules/node/node.module b/modules/node/node.module index a607fd788..60c9af813 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -334,8 +334,15 @@ function node_filter_link($text) { } function node_filter_line($text) { + /* - ** If HTML mark-up is being used, strip regular mark-up: + ** This "line break filter" will try to get the line breaks right + ** regardless of the user's input. Its goal aspires a consistent + ** mark-up and use of line breaks and paragraphs. + */ + + /* + ** If HTML mark-up is being used, strip regular line breaks: */ if (strstr($text, "<br />") || strstr($text, "<p>")) { @@ -349,10 +356,10 @@ function node_filter_line($text) { $text = eregi_replace("<br>", "\n", $text); $text = eregi_replace("<br />", "\n", $text); $text = eregi_replace("<p>", "\n", $text); - $text = eregi_replace("<br />", "\n", $text); + $text = eregi_replace("<p />", "\n", $text); /* - ** Replace "\r\n" by "\n": + ** Replace '\r\n' by '\n': */ $text = ereg_replace("\r\n", "\n", $text); @@ -365,6 +372,13 @@ function node_filter_line($text) { $text = ereg_replace("\n\n\n", "\n\n", $text); } + /* + ** Replace some common "artifacts": + */ + + $list = "blockquote|li|ol|ul|table|th|td|tr|pre"; + $text = preg_replace(array("/\n\s*<([\/])($list)/", "/($list)>\s*\n/"), array("<$1$2", "$1>"), $text); + return trim($text); } |