From 315784444af3145e6afba210731f0104d21f9db3 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Jul 2012 01:11:19 -0700 Subject: [PATCH] try and get unadulterated bb2md2html2bb for simple stuff, then we'll work up to harder stuff --- include/bb2diaspora.php | 4 ++-- include/bbcode.php | 6 +++++- include/html2bbcode.php | 2 +- mod/babel.php | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 77a5f5c2a..f17e7b549 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -38,8 +38,8 @@ function diaspora2bb($s) { $s = Markdown($s); $s = str_replace('#','#',$s); - - $s = str_replace("\n",'
',$s); +// we seem to have double linebreaks +// $s = str_replace("\n",'
',$s); $s = html2bbcode($s); // $s = str_replace('*','*',$s); diff --git a/include/bbcode.php b/include/bbcode.php index 9071c767b..1c6ce1d45 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -93,11 +93,15 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // Convert new line chars to html
tags - $Text = nl2br($Text); + +// $Text = nl2br($Text); + $Text = str_replace(array("\r","\n"), array('
','
'), $Text); + if($preserve_nl) $Text = str_replace(array("\n","\r"), array('',''),$Text); + // Set up the parameters for a URL search string $URLSearchString = "^\[\]"; // Set up the parameters for a MAIL search string diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 69ccf41b7..985c36eaa 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -124,7 +124,7 @@ function html2bbcode($message) $node->nodeValue = str_replace("\n", "\r", $node->nodeValue); $message = $doc->saveHTML(); - $message = str_replace(array("\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"), array("<", ">", "
", " ", ""), $message); + $message = str_replace(array("\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"), array("<", ">", "
", " ", ""), $message); $message = preg_replace('= [\s]*=i', " ", $message); @$doc->loadHTML($message); diff --git a/mod/babel.php b/mod/babel.php index 9d87b47f0..1c881a5bd 100644 --- a/mod/babel.php +++ b/mod/babel.php @@ -43,11 +43,11 @@ function babel_content(&$a) { $bbcode = diaspora2bb($diaspora); $o .= t("bb2dia2bb: ") . EOL. EOL; - $o .= $bbcode . EOL. EOL; + $o .= visible_lf($bbcode) . EOL. EOL; $bbcode = html2bbcode($html); $o .= t("bb2md2html2bb: ") . EOL. EOL; - $o .= $bbcode . EOL. EOL; + $o .= visible_lf($bbcode) . EOL. EOL;