summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-12-22 16:34:57 +0000
committerDries Buytaert <dries@buytaert.net>2001-12-22 16:34:57 +0000
commitffc3d729580e131a5ee6eabb41be81d173d0eb16 (patch)
tree630ea3b4691d20b884a4a8c3d14f5d5c85d50fb2
parent9fa8e310d77906ebbccf9bfd9feb10cb8c27aa9f (diff)
downloadbrdo-ffc3d729580e131a5ee6eabb41be81d173d0eb16.tar.gz
brdo-ffc3d729580e131a5ee6eabb41be81d173d0eb16.tar.bz2
- Made some improvements to the line break filter/formater.
-rw-r--r--modules/node.module20
-rw-r--r--modules/node/node.module20
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);
}