- $text = trim($text);
- $text = str_replace("\r\n", "\n", $text);
-
- // Remove linefeeds inside of the table elements. See issue #6799
- $search = ["\n[th]", "[th]\n", " [th]", "\n[/th]", "[/th]\n", "[/th] ",
- "\n[td]", "[td]\n", " [td]", "\n[/td]", "[/td]\n", "[/td] ",
- "\n[tr]", "[tr]\n", " [tr]", "[tr] ", "\n[/tr]", "[/tr]\n", " [/tr]", "[/tr] ",
- "[table]\n", "[table] ", " [table]", "\n[/table]", " [/table]", "[/table] "];
- $replace = ["[th]", "[th]", "[th]", "[/th]", "[/th]", "[/th]",
- "[td]", "[td]", "[td]", "[/td]", "[/td]", "[/td]",
- "[tr]", "[tr]", "[tr]", "[tr]", "[/tr]", "[/tr]", "[/tr]", "[/tr]",
- "[table]", "[table]", "[table]", "[/table]", "[/table]", "[/table]"];
- do {
- $oldtext = $text;
- $text = str_replace($search, $replace, $text);
- } while ($oldtext != $text);
-
- // Replace these here only once
- $search = ["\n[table]", "[/table]\n"];
- $replace = ["[table]", "[/table]"];
- $text = str_replace($search, $replace, $text);
-
- // removing multiplicated newlines
- if (Config::get('system', 'remove_multiplicated_lines')) {
- $search = ["\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n",
- "\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n"];
- $replace = ["\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ", "[/attachment]",
- "[h1]", "[/h1]", "[h2]", "[/h2]", "[h3]", "[/h3]", "[h4]", "[/h4]", "[h5]", "[/h5]", "[h6]", "[/h6]"];
- do {
- $oldtext = $text;
+ // Convert new line chars to html <br /> tags
+
+ // nlbr seems to be hopelessly messed up
+ // $Text = nl2br($Text);
+
+ // We'll emulate it.
+
+ $text = trim($text);
+ $text = str_replace("\r\n", "\n", $text);
+
+ // Remove linefeeds inside of the table elements. See issue #6799
+ $search = ["\n[th]", "[th]\n", " [th]", "\n[/th]", "[/th]\n", "[/th] ",
+ "\n[td]", "[td]\n", " [td]", "\n[/td]", "[/td]\n", "[/td] ",
+ "\n[tr]", "[tr]\n", " [tr]", "[tr] ", "\n[/tr]", "[/tr]\n", " [/tr]", "[/tr] ",
+ "[table]\n", "[table] ", " [table]", "\n[/table]", " [/table]", "[/table] "];
+ $replace = ["[th]", "[th]", "[th]", "[/th]", "[/th]", "[/th]",
+ "[td]", "[td]", "[td]", "[/td]", "[/td]", "[/td]",
+ "[tr]", "[tr]", "[tr]", "[tr]", "[/tr]", "[/tr]", "[/tr]", "[/tr]",
+ "[table]", "[table]", "[table]", "[/table]", "[/table]", "[/table]"];
+ do {
+ $oldtext = $text;
+ $text = str_replace($search, $replace, $text);
+ } while ($oldtext != $text);
+
+ // Replace these here only once
+ $search = ["\n[table]", "[/table]\n"];
+ $replace = ["[table]", "[/table]"];