]> git.mxchange.org Git - friendica.git/blobdiff - mod/babel.php
admin mail list seems wrong escaped
[friendica.git] / mod / babel.php
index fcd63113e8aa268c75d066590cb495a1b98010db..51bbf7c8a4b7ef8c6382dc21aa1c2dbfaee5c59c 100644 (file)
@@ -5,12 +5,13 @@
 
 use Friendica\Content\Text;
 use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
 
 function visible_whitespace($s)
 {
        $s = str_replace(' ', ' ', $s);
 
-       return str_replace("\n", '<br />', $s);
+       return str_replace(["\r\n", "\n", "\r"], '<br />', $s);
 }
 
 function babel_content()
@@ -71,6 +72,21 @@ function babel_content()
                                        'title' => L10n::t('BBCode::toMarkdown =>  Markdown::convert => HTML::toBBCode'),
                                        'content' => visible_whitespace($bbcode4)
                                ];
+
+                               $item = [
+                                       'body' => $bbcode,
+                                       'tag' => '',
+                               ];
+
+                               \Friendica\Model\Item::setHashtags($item);
+                               $results[] = [
+                                       'title' => L10n::t('Item Body'),
+                                       'content' => visible_whitespace($item['body'])
+                               ];
+                               $results[] = [
+                                       'title' => L10n::t('Item Tags'),
+                                       'content' => $item['tag']
+                               ];
                                break;
                        case 'markdown':
                                $markdown = trim($_REQUEST['text']);
@@ -82,7 +98,7 @@ function babel_content()
                                $html = Text\Markdown::convert($markdown);
                                $results[] = [
                                        'title' => L10n::t('Markdown::convert (raw HTML)'),
-                                       'content' => htmlspecialchars($html)
+                                       'content' => visible_whitespace(htmlspecialchars($html))
                                ];
 
                                $results[] = [
@@ -114,6 +130,23 @@ function babel_content()
                                        'content' => visible_whitespace($bbcode)
                                ];
 
+                               $html2 = Text\BBCode::convert($bbcode);
+                               $results[] = [
+                                       'title' => L10n::t('HTML::toBBCode => BBCode::convert'),
+                                       'content' => $html2
+                               ];
+
+                               $results[] = [
+                                       'title' => L10n::t('HTML::toBBCode => BBCode::convert (raw HTML)'),
+                                       'content' => htmlspecialchars($html2)
+                               ];
+
+                               $markdown = Text\HTML::toMarkdown($html);
+                               $results[] = [
+                                       'title' => L10n::t('HTML::toMarkdown'),
+                                       'content' => visible_whitespace($markdown)
+                               ];
+
                                $text = Text\HTML::toPlaintext($html);
                                $results[] = [
                                        'title' => L10n::t('HTML::toPlaintext'),
@@ -122,8 +155,8 @@ function babel_content()
                }
        }
 
-       $tpl = get_markup_template('babel.tpl');
-       $o = replace_macros($tpl, [
+       $tpl = Renderer::getMarkupTemplate('babel.tpl');
+       $o = Renderer::replaceMacros($tpl, [
                '$text'          => ['text', L10n::t('Source text'), defaults($_REQUEST, 'text', ''), ''],
                '$type_bbcode'   => ['type', L10n::t('BBCode'), 'bbcode', '', defaults($_REQUEST, 'type', 'bbcode') == 'bbcode'],
                '$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', defaults($_REQUEST, 'type', 'bbcode') == 'markdown'],