try and get unadulterated bb2md2html2bb for simple stuff, then we'll work up to harder stuff

This commit is contained in:
friendica 2012-07-02 01:11:19 -07:00
parent a9c65dfe27
commit 315784444a
4 changed files with 10 additions and 6 deletions

View file

@ -38,8 +38,8 @@ function diaspora2bb($s) {
$s = Markdown($s); $s = Markdown($s);
$s = str_replace('#','#',$s); $s = str_replace('#','#',$s);
// we seem to have double linebreaks
$s = str_replace("\n",'<br />',$s); // $s = str_replace("\n",'<br />',$s);
$s = html2bbcode($s); $s = html2bbcode($s);
// $s = str_replace('&#42;','*',$s); // $s = str_replace('&#42;','*',$s);

View file

@ -93,11 +93,15 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// Convert new line chars to html <br /> tags // Convert new line chars to html <br /> tags
$Text = nl2br($Text);
// $Text = nl2br($Text);
$Text = str_replace(array("\r","\n"), array('<br />','<br />'), $Text);
if($preserve_nl) if($preserve_nl)
$Text = str_replace(array("\n","\r"), array('',''),$Text); $Text = str_replace(array("\n","\r"), array('',''),$Text);
// Set up the parameters for a URL search string // Set up the parameters for a URL search string
$URLSearchString = "^\[\]"; $URLSearchString = "^\[\]";
// Set up the parameters for a MAIL search string // Set up the parameters for a MAIL search string

View file

@ -124,7 +124,7 @@ function html2bbcode($message)
$node->nodeValue = str_replace("\n", "\r", $node->nodeValue); $node->nodeValue = str_replace("\n", "\r", $node->nodeValue);
$message = $doc->saveHTML(); $message = $doc->saveHTML();
$message = str_replace(array("\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"), array("<", ">", "<br>", " ", ""), $message); $message = str_replace(array("\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"), array("<", ">", "<br />", " ", ""), $message);
$message = preg_replace('= [\s]*=i', " ", $message); $message = preg_replace('= [\s]*=i', " ", $message);
@$doc->loadHTML($message); @$doc->loadHTML($message);

View file

@ -43,11 +43,11 @@ function babel_content(&$a) {
$bbcode = diaspora2bb($diaspora); $bbcode = diaspora2bb($diaspora);
$o .= t("bb2dia2bb: ") . EOL. EOL; $o .= t("bb2dia2bb: ") . EOL. EOL;
$o .= $bbcode . EOL. EOL; $o .= visible_lf($bbcode) . EOL. EOL;
$bbcode = html2bbcode($html); $bbcode = html2bbcode($html);
$o .= t("bb2md2html2bb: ") . EOL. EOL; $o .= t("bb2md2html2bb: ") . EOL. EOL;
$o .= $bbcode . EOL. EOL; $o .= visible_lf($bbcode) . EOL. EOL;