aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/bb2diaspora.php4
-rw-r--r--include/bbcode.php6
-rw-r--r--include/html2bbcode.php2
-rw-r--r--mod/babel.php56
4 files changed, 64 insertions, 4 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",'<br />',$s);
+// we seem to have double linebreaks
+// $s = str_replace("\n",'<br />',$s);
$s = html2bbcode($s);
// $s = str_replace('&#42;','*',$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 <br /> tags
- $Text = nl2br($Text);
+
+// $Text = nl2br($Text);
+ $Text = str_replace(array("\r","\n"), array('<br />','<br />'), $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("<", ">", "<br>", " ", ""), $message);
+ $message = str_replace(array("\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"), array("<", ">", "<br />", " ", ""), $message);
$message = preg_replace('= [\s]*=i', " ", $message);
@$doc->loadHTML($message);
diff --git a/mod/babel.php b/mod/babel.php
new file mode 100644
index 000000000..1c881a5bd
--- /dev/null
+++ b/mod/babel.php
@@ -0,0 +1,56 @@
+<?php
+
+require_once('include/bbcode.php');
+require_once('library/markdown.php');
+require_once('include/bb2diaspora.php');
+require_once('include/html2bbcode.php');
+
+function visible_lf($s) {
+ return str_replace("\n",'<br />', $s);
+}
+
+function babel_content(&$a) {
+
+ $o .= '<h3>Babel Diagnostic</h3>';
+
+ $o .= '<form action="babel" method="post">';
+ $o .= t('Source (bbcode) text:') . EOL . '<textarea name="text" >' . htmlspecialchars($_REQUEST['text']) .'</textarea>' . EOL;
+ $o .= '<input type="submit" name="submit" value="Submit" /></form>';
+
+ $o .= '<br /><br />';
+
+ if(x($_REQUEST,'text')) {
+
+ $text = trim($_REQUEST['text']);
+ $o .= t("Source input: ") . EOL. EOL;
+ $o .= visible_lf($text) . EOL. EOL;
+
+ $html = bbcode($text);
+ $o .= t("bb2html: ") . EOL. EOL;
+ $o .= $html. EOL. EOL;
+
+ $bbcode = html2bbcode($html);
+ $o .= t("bb2html2bb: ") . EOL. EOL;
+ $o .= visible_lf($bbcode) . EOL. EOL;
+
+ $diaspora = bb2diaspora($text);
+ $o .= t("bb2md: ") . EOL. EOL;
+ $o .= visible_lf($diaspora) . EOL. EOL;
+
+ $html = Markdown($diaspora);
+ $o .= t("bb2md2html: ") . EOL. EOL;
+ $o .= $html. EOL. EOL;
+
+ $bbcode = diaspora2bb($diaspora);
+ $o .= t("bb2dia2bb: ") . EOL. EOL;
+ $o .= visible_lf($bbcode) . EOL. EOL;
+
+ $bbcode = html2bbcode($html);
+ $o .= t("bb2md2html2bb: ") . EOL. EOL;
+ $o .= visible_lf($bbcode) . EOL. EOL;
+
+
+
+ }
+ return $o;
+}