summaryrefslogtreecommitdiff
path: root/modules/node.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-11-20 20:44:32 +0000
committerDries Buytaert <dries@buytaert.net>2001-11-20 20:44:32 +0000
commitc35019601ed1d1453f527c5ebb8d5664d5a2a2ef (patch)
treebd37404f84fe6600bf2e1393f6283d198c3f8d06 /modules/node.module
parent90e207267f76c76cd020b873d52975244b278319 (diff)
downloadbrdo-c35019601ed1d1453f527c5ebb8d5664d5a2a2ef.tar.gz
brdo-c35019601ed1d1453f527c5ebb8d5664d5a2a2ef.tar.bz2
- added a "line" filter
Diffstat (limited to 'modules/node.module')
-rw-r--r--modules/node.module38
1 files changed, 37 insertions, 1 deletions
diff --git a/modules/node.module b/modules/node.module
index 0dbc9ba48..b310b30e9 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, "<br />") || strstr($text, "<p>")) {
+ $text = ereg_replace("[\r\n\t\v]", "", $text);
+ }
+
+ /*
+ ** Replace '<br>', '<br />', '<p>' and '<p />' by '\n':
+ */
+
+ $text = eregi_replace("<br>", "\n", $text);
+ $text = eregi_replace("<br />", "\n", $text);
+ $text = eregi_replace("<p>", "\n", $text);
+ $text = eregi_replace("<br />", "\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) {