6 use Friendica\Content\Text\BBCode;
7 use Friendica\Content\Text\Markdown;
8 use Friendica\Core\L10n;
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 \x28bbcode\x29 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 \x28Diaspora\x29 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::convert($text);
41 $o .= '<h2>' . L10n::t("bbcode \x28raw HTML\x28: ") . '</h2>' . EOL . EOL;
42 $o .= htmlspecialchars($html) . EOL . EOL;
44 $o .= '<h2>' . L10n::t('bbcode: ') . '</h2>' . EOL . EOL;
45 $o .= $html . EOL . EOL;
47 $bbcode = html2bbcode($html);
48 $o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
49 $o .= visible_lf($bbcode) . EOL . EOL;
51 $diaspora = BBCode::toMarkdown($text);
52 $o .= '<h2>' . L10n::t('BBCode::toMarkdown: ') . '</h2>' . EOL . EOL;
53 $o .= visible_lf($diaspora) . EOL . EOL;
55 $html = Markdown::convert($diaspora);
56 $o .= '<h2>' . L10n::t('BBCode::toMarkdown => Markdown::convert: ') . '</h2>' . EOL . EOL;
57 $o .= $html . EOL . EOL;
59 $bbcode = Markdown::toBBCode($diaspora);
60 $o .= '<h2>' . L10n::t('BBCode::toMarkdown => Markdown::toBBCode: ') . '</h2>' . EOL . EOL;
61 $o .= visible_lf($bbcode) . EOL . EOL;
63 $bbcode = html2bbcode($html);
64 $o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
65 $o .= visible_lf($bbcode) . EOL . EOL;
68 if (x($_REQUEST, 'd2bbtext')) {
69 $d2bbtext = trim($_REQUEST['d2bbtext']);
70 $o .= '<h2>' . L10n::t("Source input \x28Diaspora format\x29: ") . '</h2>' . EOL . EOL;
71 $o .= '<pre>' . $d2bbtext . '</pre>' . EOL . EOL;
73 $bb = Markdown::toBBCode($d2bbtext);
74 $o .= '<h2>' . L10n::t('diaspora2bb: ') . '</h2>' . EOL . EOL;
75 $o .= '<pre>' . $bb . '</pre>' . EOL . EOL;