From ffc3d729580e131a5ee6eabb41be81d173d0eb16 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 22 Dec 2001 16:34:57 +0000 Subject: - Made some improvements to the line break filter/formater. --- modules/node.module | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'modules/node.module') 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, "
") || strstr($text, "

")) { @@ -349,10 +356,10 @@ function node_filter_line($text) { $text = eregi_replace("
", "\n", $text); $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": + ** 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); } -- cgit v1.2.3