Commit ffc3d729 authored by Dries's avatar Dries
Browse files

- Made some improvements to the line break filter/formater.
parent 9fa8e310
...@@ -334,8 +334,15 @@ function node_filter_link($text) { ...@@ -334,8 +334,15 @@ function node_filter_link($text) {
} }
function node_filter_line($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>")) { if (strstr($text, "<br />") || strstr($text, "<p>")) {
...@@ -349,10 +356,10 @@ function node_filter_line($text) { ...@@ -349,10 +356,10 @@ function node_filter_line($text) {
$text = eregi_replace("<br>", "\n", $text); $text = eregi_replace("<br>", "\n", $text);
$text = eregi_replace("<br />", "\n", $text); $text = eregi_replace("<br />", "\n", $text);
$text = eregi_replace("<p>", "\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); $text = ereg_replace("\r\n", "\n", $text);
...@@ -365,6 +372,13 @@ function node_filter_line($text) { ...@@ -365,6 +372,13 @@ function node_filter_line($text) {
$text = ereg_replace("\n\n\n", "\n\n", $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); return trim($text);
} }
......
...@@ -334,8 +334,15 @@ function node_filter_link($text) { ...@@ -334,8 +334,15 @@ function node_filter_link($text) {
} }
function node_filter_line($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>")) { if (strstr($text, "<br />") || strstr($text, "<p>")) {
...@@ -349,10 +356,10 @@ function node_filter_line($text) { ...@@ -349,10 +356,10 @@ function node_filter_line($text) {
$text = eregi_replace("<br>", "\n", $text); $text = eregi_replace("<br>", "\n", $text);
$text = eregi_replace("<br />", "\n", $text); $text = eregi_replace("<br />", "\n", $text);
$text = eregi_replace("<p>", "\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); $text = ereg_replace("\r\n", "\n", $text);
...@@ -365,6 +372,13 @@ function node_filter_line($text) { ...@@ -365,6 +372,13 @@ function node_filter_line($text) {
$text = ereg_replace("\n\n\n", "\n\n", $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); return trim($text);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment