6 use Friendica\Content\Text\BBCode;
7 use Friendica\Content\Text\Markdown;
8 use Friendica\Core\L10n;
10 require_once 'include/bbcode.php';
11 require_once 'include/bb2diaspora.php';
12 require_once 'include/html2bbcode.php';
14 function visible_lf($s)
16 return str_replace("\n", '<br />', $s);
19 function babel_content()
21 $o = '<h1>Babel Diagnostic</h1>';
23 $o .= '<form action="babel" method="post">';
24 $o .= L10n::t("Source \x28bbcode\x29 text:") . EOL;
25 $o .= '<textarea name="text" cols="80" rows="10">' . htmlspecialchars($_REQUEST['text']) . '</textarea>' . EOL;
26 $o .= '<input type="submit" name="submit" value="Submit" /></form>';
30 $o .= '<form action="babel" method="post">';
31 $o .= L10n::t("Source \x28Diaspora\x29 text to convert to BBcode:") . EOL;
32 $o .= '<textarea name="d2bbtext" cols="80" rows="10">' . htmlspecialchars($_REQUEST['d2bbtext']) . '</textarea>' . EOL;
33 $o .= '<input type="submit" name="submit" value="Submit" /></form>';
37 if (x($_REQUEST, 'text')) {
38 $text = trim($_REQUEST['text']);
39 $o .= '<h2>' . L10n::t('Source input: ') . '</h2>' . EOL . EOL;
40 $o .= visible_lf($text) . EOL . EOL;
42 $html = BBCode::convert($text);
43 $o .= '<h2>' . L10n::t("bbcode \x28raw HTML\x28: ") . '</h2>' . EOL . EOL;
44 $o .= htmlspecialchars($html) . EOL . EOL;
46 //$html = bbcode($text);
47 $o .= '<h2>' . L10n::t('bbcode: ') . '</h2>' . EOL . EOL;
48 $o .= $html . EOL . EOL;
50 $bbcode = html2bbcode($html);
51 $o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
52 $o .= visible_lf($bbcode) . EOL . EOL;
54 $diaspora = bb2diaspora($text);
55 $o .= '<h2>' . L10n::t('bb2diaspora: ') . '</h2>' . EOL . EOL;
56 $o .= visible_lf($diaspora) . EOL . EOL;
58 $html = Markdown::convert($diaspora);
59 $o .= '<h2>' . L10n::t('bb2diaspora => Markdown: ') . '</h2>' . EOL . EOL;
60 $o .= $html . EOL . EOL;
62 $bbcode = diaspora2bb($diaspora);
63 $o .= '<h2>' . L10n::t('bb2diaspora => diaspora2bb: ') . '</h2>' . EOL . EOL;
64 $o .= visible_lf($bbcode) . EOL . EOL;
66 $bbcode = html2bbcode($html);
67 $o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
68 $o .= visible_lf($bbcode) . EOL . EOL;
71 if (x($_REQUEST, 'd2bbtext')) {
72 $d2bbtext = trim($_REQUEST['d2bbtext']);
73 $o .= '<h2>' . L10n::t("Source input \x28Diaspora format\x29: ") . '</h2>' . EOL . EOL;
74 $o .= '<pre>' . $d2bbtext . '</pre>' . EOL . EOL;
76 $bb = diaspora2bb($d2bbtext);
77 $o .= '<h2>' . L10n::t('diaspora2bb: ') . '</h2>' . EOL . EOL;
78 $o .= '<pre>' . $bb . '</pre>' . EOL . EOL;