Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.3 KiB

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