From c35019601ed1d1453f527c5ebb8d5664d5a2a2ef Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 20 Nov 2001 20:44:32 +0000 Subject: [PATCH] - added a "line" filter --- modules/node.module | 38 +++++++++++++++++++++++++++++++++++++- modules/node/node.module | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/modules/node.module b/modules/node.module index 0dbc9ba48f8..b310b30e991 100644 --- a/modules/node.module +++ b/modules/node.module @@ -87,10 +87,46 @@ function node_filter_link($text) { return preg_replace($src, $dst, $text); } +function node_filter_line($text) { + + /* + ** If HTML mark-up is being used, strip regular mark-up: + */ + + if (strstr($text, "
") || strstr($text, "

")) { + $text = ereg_replace("[\r\n\t\v]", "", $text); + } + + /* + ** Replace '
', '
', '

' and '

' by '\n': + */ + + $text = eregi_replace("
", "\n", $text); + $text = eregi_replace("
", "\n", $text); + $text = eregi_replace("

", "\n", $text); + $text = eregi_replace("
", "\n", $text); + + /* + ** Replace "\r\n" by "\n": + */ + + $text = ereg_replace("\r\n", "\n", $text); + + /* + ** Replace some new line charachters: + */ + + while (strpos($text, "\n\n\n")) { + $text = ereg_replace("\n\n\n", "\n\n", $text); + } + + return trim($text); +} + function node_filter($text) { if (variable_get("filter_html", 0)) $text = node_filter_html($text); if (variable_get("filter_link", 0)) $text = node_filter_link($text); - return trim($text); + return node_filter_line($text); } function node_link($type, $node = 0) { diff --git a/modules/node/node.module b/modules/node/node.module index 0dbc9ba48f8..b310b30e991 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -87,10 +87,46 @@ function node_filter_link($text) { return preg_replace($src, $dst, $text); } +function node_filter_line($text) { + + /* + ** If HTML mark-up is being used, strip regular mark-up: + */ + + if (strstr($text, "
") || strstr($text, "

")) { + $text = ereg_replace("[\r\n\t\v]", "", $text); + } + + /* + ** Replace '
', '
', '

' and '

' by '\n': + */ + + $text = eregi_replace("
", "\n", $text); + $text = eregi_replace("
", "\n", $text); + $text = eregi_replace("

", "\n", $text); + $text = eregi_replace("
", "\n", $text); + + /* + ** Replace "\r\n" by "\n": + */ + + $text = ereg_replace("\r\n", "\n", $text); + + /* + ** Replace some new line charachters: + */ + + while (strpos($text, "\n\n\n")) { + $text = ereg_replace("\n\n\n", "\n\n", $text); + } + + return trim($text); +} + function node_filter($text) { if (variable_get("filter_html", 0)) $text = node_filter_html($text); if (variable_get("filter_link", 0)) $text = node_filter_link($text); - return trim($text); + return node_filter_line($text); } function node_link($type, $node = 0) {