]> git.mxchange.org Git - friendica.git/blob - mod/babel.php
"babel" diagnostic - convert bbcode to different formats and back again
[friendica.git] / mod / babel.php
1 <?php
2
3 require_once('include/bbcode.php');
4 require_once('library/markdown.php');
5 require_once('include/bb2diaspora.php');
6 require_once('include/html2bbcode.php');
7
8 function visible_lf($s) {
9         return str_replace("\n",'<br />', $s);
10 }
11
12 function babel_content(&$a) {
13
14         $o .= '<h3>Babel Diagnostic</h3>';
15
16         $o .= '<form action="babel" method="post">';
17         $o .= t('Source (bbcode) text:') . EOL . '<textarea name="text" >' . htmlspecialchars($_REQUEST['text']) .'</textarea>' . EOL;
18         $o .= '<input type="submit" name="submit" value="Submit" /></form>'; 
19
20         $o .= '<br /><br />';
21
22         if(x($_REQUEST,'text')) {
23
24                 $text = trim($_REQUEST['text']);
25                 $o .= t("Source input: ") . EOL. EOL; 
26                 $o .= visible_lf($text) . EOL. EOL; 
27
28                 $html = bbcode($text);
29                 $o .= t("bb2html: ") . EOL. EOL; 
30                 $o .= $html. EOL. EOL; 
31
32                 $bbcode = html2bbcode($html);
33                 $o .= t("bb2html2bb: ") . EOL. EOL; 
34                 $o .= visible_lf($bbcode) . EOL. EOL; 
35
36                 $diaspora = bb2diaspora($text);
37                 $o .= t("bb2md: ") . EOL. EOL; 
38                 $o .= visible_lf($diaspora) . EOL. EOL; 
39
40                 $html = Markdown($diaspora);
41                 $o .= t("bb2md2html: ") . EOL. EOL; 
42                 $o .= $html. EOL. EOL; 
43
44                 $bbcode = diaspora2bb($diaspora);
45                 $o .= t("bb2dia2bb: ") . EOL. EOL; 
46                 $o .= $bbcode . EOL. EOL; 
47
48                 $bbcode = html2bbcode($html);
49                 $o .= t("bb2md2html2bb: ") . EOL. EOL; 
50                 $o .= $bbcode . EOL. EOL; 
51
52
53
54         }
55         return $o;
56 }