5 use Friendica\Content\Text\Markdown;
6 use Friendica\Core\L10n;
8 require_once 'include/bbcode.php';
9 require_once 'include/bb2diaspora.php';
10 require_once 'include/html2bbcode.php';
12 function visible_lf($s)
14 return str_replace("\n", '<br />', $s);
17 function babel_content()
19 $o = '<h1>Babel Diagnostic</h1>';
21 $o .= '<form action="babel" method="post">';
22 $o .= L10n::t('Source (bbcode) text:') . EOL;
23 $o .= '<textarea name="text" cols="80" rows="10">' . htmlspecialchars($_REQUEST['text']) . '</textarea>' . EOL;
24 $o .= '<input type="submit" name="submit" value="Submit" /></form>';
28 $o .= '<form action="babel" method="post">';
29 $o .= L10n::t('Source (Diaspora) text to convert to BBcode:') . EOL;
30 $o .= '<textarea name="d2bbtext" cols="80" rows="10">' . htmlspecialchars($_REQUEST['d2bbtext']) . '</textarea>' . EOL;
31 $o .= '<input type="submit" name="submit" value="Submit" /></form>';
35 if (x($_REQUEST, 'text')) {
36 $text = trim($_REQUEST['text']);
37 $o .= '<h2>' . L10n::t('Source input: ') . '</h2>' . EOL . EOL;
38 $o .= visible_lf($text) . EOL . EOL;
40 $html = bbcode($text);
41 $o .= '<h2>' . L10n::t('bbcode (raw HTML): ') . '</h2>' . EOL . EOL;
42 $o .= htmlspecialchars($html) . EOL . EOL;
44 //$html = bbcode($text);
45 $o .= '<h2>' . L10n::t('bbcode: ') . '</h2>' . EOL . EOL;
46 $o .= $html . EOL . EOL;
48 $bbcode = html2bbcode($html);
49 $o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
50 $o .= visible_lf($bbcode) . EOL . EOL;
52 $diaspora = bb2diaspora($text);
53 $o .= '<h2>' . L10n::t('bb2diaspora: ') . '</h2>' . EOL . EOL;
54 $o .= visible_lf($diaspora) . EOL . EOL;
56 $html = Markdown::convert($diaspora);
57 $o .= '<h2>' . L10n::t('bb2diaspora => Markdown: ') . '</h2>' . EOL . EOL;
58 $o .= $html . EOL . EOL;
60 $bbcode = diaspora2bb($diaspora);
61 $o .= '<h2>' . L10n::t('bb2diaspora => diaspora2bb: ') . '</h2>' . EOL . EOL;
62 $o .= visible_lf($bbcode) . EOL . EOL;
64 $bbcode = html2bbcode($html);
65 $o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
66 $o .= visible_lf($bbcode) . EOL . EOL;
69 if (x($_REQUEST, 'd2bbtext')) {
70 $d2bbtext = trim($_REQUEST['d2bbtext']);
71 $o .= '<h2>' . L10n::t('Source input (Diaspora format): ') . '</h2>' . EOL . EOL;
72 $o .= '<pre>' . $d2bbtext . '</pre>' . EOL . EOL;
74 $bb = diaspora2bb($d2bbtext);
75 $o .= '<h2>' . L10n::t('diaspora2bb: ') . '</h2>' . EOL . EOL;
76 $o .= '<pre>' . $bb . '</pre>' . EOL . EOL;