X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FDebug%2FBabel.php;h=ecad73f4dcd82eee64b5bd39415b2883f9efbffc;hb=f58d42e317cbf323fb2c802a0cb71a4799863008;hp=4b3b47f6490d156c7e6468e35a0b3d975aee53fa;hpb=ab8997f9db910ba70c592bf106a7f5fc41a55b2d;p=friendica.git
diff --git a/src/Module/Debug/Babel.php b/src/Module/Debug/Babel.php
index 4b3b47f649..ecad73f4dc 100644
--- a/src/Module/Debug/Babel.php
+++ b/src/Module/Debug/Babel.php
@@ -1,4 +1,23 @@
.
+ *
+ */
namespace Friendica\Module\Debug;
@@ -7,6 +26,7 @@ use Friendica\Content\Text;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Item;
+use Friendica\Model\Tag;
use Friendica\Util\XML;
/**
@@ -18,9 +38,7 @@ class Babel extends BaseModule
{
function visible_whitespace($s)
{
- $s = str_replace(' ', ' ', $s);
-
- return str_replace(["\r\n", "\n", "\r"], '
', $s);
+ return '
' . htmlspecialchars($s) . ''; } $results = []; @@ -42,7 +60,7 @@ class Babel extends BaseModule $html = Text\BBCode::convert($bbcode); $results[] = [ 'title' => DI::l10n()->t('BBCode::convert (raw HTML)'), - 'content' => visible_whitespace(htmlspecialchars($html)) + 'content' => visible_whitespace($html) ]; $results[] = [ @@ -59,13 +77,13 @@ class Babel extends BaseModule $markdown = Text\BBCode::toMarkdown($bbcode); $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown'), - 'content' => visible_whitespace(htmlspecialchars($markdown)) + 'content' => visible_whitespace($markdown) ]; $html2 = Text\Markdown::convert($markdown); $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert (raw HTML)'), - 'content' => visible_whitespace(htmlspecialchars($html2)) + 'content' => visible_whitespace($html2) ]; $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert'), @@ -84,10 +102,9 @@ class Babel extends BaseModule 'content' => visible_whitespace($bbcode4) ]; - $item = [ - 'body' => $bbcode, - 'tag' => '', - ]; + $item = ['body' => $bbcode]; + + $tags = Text\BBCode::getTags($bbcode); Item::setHashtags($item); $results[] = [ @@ -96,20 +113,31 @@ class Babel extends BaseModule ]; $results[] = [ 'title' => DI::l10n()->t('Item Tags'), - 'content' => $item['tag'] + 'content' => visible_whitespace(var_export($tags, true)), ]; break; - case 'markdown': - $markdown = trim($_REQUEST['text']); + case 'diaspora': + $diaspora = trim($_REQUEST['text']); $results[] = [ 'title' => DI::l10n()->t('Source input (Diaspora format)'), - 'content' => '
' . htmlspecialchars($markdown) . '' + 'content' => visible_whitespace($diaspora), + ]; + + $markdown = XML::unescape($diaspora); + case 'markdown': + if (!isset($markdown)) { + $markdown = trim($_REQUEST['text']); + } + + $results[] = [ + 'title' => DI::l10n()->t('Source input (Markdown)'), + 'content' => visible_whitespace($markdown), ]; - $html = Text\Markdown::convert(html_entity_decode($markdown,ENT_COMPAT, 'UTF-8')); + $html = Text\Markdown::convert($markdown); $results[] = [ 'title' => DI::l10n()->t('Markdown::convert (raw HTML)'), - 'content' => visible_whitespace(htmlspecialchars($html)) + 'content' => visible_whitespace($html), ]; $results[] = [ @@ -117,17 +145,17 @@ class Babel extends BaseModule 'content' => $html ]; - $bbcode = Text\Markdown::toBBCode(XML::unescape($markdown)); + $bbcode = Text\Markdown::toBBCode($markdown); $results[] = [ 'title' => DI::l10n()->t('Markdown::toBBCode'), - 'content' => '
' . $bbcode . '' + 'content' => visible_whitespace($bbcode), ]; break; case 'html' : $html = trim($_REQUEST['text']); $results[] = [ 'title' => DI::l10n()->t('Raw HTML input'), - 'content' => htmlspecialchars($html) + 'content' => visible_whitespace($html), ]; $results[] = [ @@ -155,7 +183,7 @@ class Babel extends BaseModule $bbcode2plain = Text\BBCode::toPlaintext($bbcode); $results[] = [ 'title' => DI::l10n()->t('HTML::toBBCode => BBCode::toPlaintext'), - 'content' => '
' . $bbcode2plain . '' + 'content' => visible_whitespace($bbcode2plain), ]; $markdown = Text\HTML::toMarkdown($html); @@ -167,13 +195,13 @@ class Babel extends BaseModule $text = Text\HTML::toPlaintext($html, 0); $results[] = [ 'title' => DI::l10n()->t('HTML::toPlaintext'), - 'content' => '
' . $text . '' + 'content' => visible_whitespace($text), ]; $text = Text\HTML::toPlaintext($html, 0, true); $results[] = [ 'title' => DI::l10n()->t('HTML::toPlaintext (compact)'), - 'content' => '
' . $text . '' + 'content' => visible_whitespace($text), ]; } } @@ -182,6 +210,7 @@ class Babel extends BaseModule $o = Renderer::replaceMacros($tpl, [ '$text' => ['text', DI::l10n()->t('Source text'), $_REQUEST['text'] ?? '', ''], '$type_bbcode' => ['type', DI::l10n()->t('BBCode'), 'bbcode', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'bbcode'], + '$type_diaspora' => ['type', DI::l10n()->t('Diaspora'), 'diaspora', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'diaspora'], '$type_markdown' => ['type', DI::l10n()->t('Markdown'), 'markdown', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'markdown'], '$type_html' => ['type', DI::l10n()->t('HTML'), 'html', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'html'], '$results' => $results