Add some more result panels to Babel

This commit is contained in:
Hypolite Petovan 2020-12-04 07:28:18 -05:00
parent a0f6d678c4
commit a382798999
2 changed files with 26 additions and 4 deletions

View file

@ -49,7 +49,7 @@ class Babel extends BaseModule
if (!empty($_REQUEST['text'])) {
switch (($_REQUEST['type'] ?? '') ?: 'bbcode') {
case 'bbcode':
$bbcode = trim($_REQUEST['text']);
$bbcode = $_REQUEST['text'];
$results[] = [
'title' => DI::l10n()->t('Source input'),
'content' => visible_whitespace($bbcode)
@ -67,6 +67,11 @@ class Babel extends BaseModule
'content' => visible_whitespace($html)
];
$results[] = [
'title' => DI::l10n()->t('BBCode::convert (hex)'),
'content' => visible_whitespace(bin2hex($html)),
];
$results[] = [
'title' => DI::l10n()->t('BBCode::convert'),
'content' => $html
@ -178,6 +183,25 @@ class Babel extends BaseModule
'content' => $html
];
$config = \HTMLPurifier_Config::createDefault();
$HTMLPurifier = new \HTMLPurifier($config);
$purified = $HTMLPurifier->purify($html);
$results[] = [
'title' => DI::l10n()->t('HTML Purified (raw)'),
'content' => visible_whitespace($purified),
];
$results[] = [
'title' => DI::l10n()->t('HTML Purified (hex)'),
'content' => visible_whitespace(bin2hex($purified)),
];
$results[] = [
'title' => DI::l10n()->t('HTML Purified'),
'content' => $purified,
];
$bbcode = Text\HTML::toBBCode($html);
$results[] = [
'title' => DI::l10n()->t('HTML::toBBCode'),

View file

@ -24,9 +24,7 @@
<div class="panel-heading">
<h3 class="panel-title">{{$result.title}}</h3>
</div>
<div class="panel-body">
{{$result.content nofilter}}
</div>
<div class="panel-body">{{$result.content nofilter}}</div>
</div>
{{/foreach}}
</div>