{
$results = [];
+ $visible_whitespace = function (string $s): string {
+ return '<pre>' . htmlspecialchars($s) . '</pre>';
+ };
+
if (!empty($_REQUEST['source'])) {
try {
$source = json_decode($_REQUEST['source'], true);
$formatted = json_encode($source, JSON_PRETTY_PRINT);
$results[] = [
'title' => DI::l10n()->t('Formatted'),
- 'content' => $this->visible_whitespace(trim(var_export($formatted, true), "'")),
+ 'content' => $visible_whitespace(trim(var_export($formatted, true), "'")),
];
$results[] = [
'title' => DI::l10n()->t('Source'),
- 'content' => $this->visible_whitespace(var_export($source, true))
+ 'content' => $visible_whitespace(var_export($source, true))
];
$activity = JsonLD::compact($source);
if (!$activity) {
}
$results[] = [
'title' => DI::l10n()->t('Activity'),
- 'content' => $this->visible_whitespace(var_export($activity, true))
+ 'content' => $visible_whitespace(var_export($activity, true))
];
$type = JsonLD::fetchElement($activity, '@type');
$results[] = [
'title' => DI::l10n()->t('Object data'),
- 'content' => $this->visible_whitespace(var_export($object_data, true))
+ 'content' => $visible_whitespace(var_export($object_data, true))
];
$item = ActivityPub\Processor::createItem($object_data, true);
$results[] = [
'title' => DI::l10n()->t('Result Item'),
- 'content' => $this->visible_whitespace(var_export($item, true))
+ 'content' => $visible_whitespace(var_export($item, true))
];
} catch (\Throwable $e) {
$results[] = [
return $o;
}
-
- private function visible_whitespace(string $s): string
- {
- return '<pre>' . htmlspecialchars($s) . '</pre>';
- }
}
protected function content(array $request = []): string
{
$results = [];
+
+ $visible_whitespace = function (string $s): string {
+ return '<pre>' . htmlspecialchars($s) . '</pre>';
+ };
+
if (!empty($request['text'])) {
self::checkFormSecurityTokenForbiddenOnError('babel');
switch (($request['type'] ?? '') ?: 'bbcode') {
$bbcode = $request['text'];
$results[] = [
'title' => DI::l10n()->t('Source input'),
- 'content' => $this->visible_whitespace($bbcode)
+ 'content' => $visible_whitespace($bbcode)
];
$plain = Text\BBCode::toPlaintext($bbcode, false);
$results[] = [
'title' => DI::l10n()->t('BBCode::toPlaintext'),
- 'content' => $this->visible_whitespace($plain)
+ 'content' => $visible_whitespace($plain)
];
$html = Text\BBCode::convertForUriId(0, $bbcode);
$results[] = [
'title' => DI::l10n()->t('BBCode::convert (raw HTML)'),
- 'content' => $this->visible_whitespace($html)
+ 'content' => $visible_whitespace($html)
];
$results[] = [
'title' => DI::l10n()->t('BBCode::convert (hex)'),
- 'content' => $this->visible_whitespace(bin2hex($html)),
+ 'content' => $visible_whitespace(bin2hex($html)),
];
$results[] = [
$bbcode2 = Text\HTML::toBBCode($html);
$results[] = [
'title' => DI::l10n()->t('BBCode::convert => HTML::toBBCode'),
- 'content' => $this->visible_whitespace($bbcode2)
+ 'content' => $visible_whitespace($bbcode2)
];
$markdown = Text\BBCode::toMarkdown($bbcode);
$results[] = [
'title' => DI::l10n()->t('BBCode::toMarkdown'),
- 'content' => $this->visible_whitespace($markdown)
+ 'content' => $visible_whitespace($markdown)
];
$html2 = Text\Markdown::convert($markdown);
$results[] = [
'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert (raw HTML)'),
- 'content' => $this->visible_whitespace($html2)
+ 'content' => $visible_whitespace($html2)
];
$results[] = [
'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert'),
$bbcode3 = Text\Markdown::toBBCode($markdown);
$results[] = [
'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::toBBCode'),
- 'content' => $this->visible_whitespace($bbcode3)
+ 'content' => $visible_whitespace($bbcode3)
];
$bbcode4 = Text\HTML::toBBCode($html2);
$results[] = [
'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert => HTML::toBBCode'),
- 'content' => $this->visible_whitespace($bbcode4)
+ 'content' => $visible_whitespace($bbcode4)
];
$tags = Text\BBCode::getTags($bbcode);
$body = Item::setHashtags($bbcode);
$results[] = [
'title' => DI::l10n()->t('Item Body'),
- 'content' => $this->visible_whitespace($body)
+ 'content' => $visible_whitespace($body)
];
$results[] = [
'title' => DI::l10n()->t('Item Tags'),
- 'content' => $this->visible_whitespace(var_export($tags, true)),
+ 'content' => $visible_whitespace(var_export($tags, true)),
];
$body2 = PageInfo::searchAndAppendToBody($bbcode, true);
$results[] = [
'title' => DI::l10n()->t('PageInfo::appendToBody'),
- 'content' => $this->visible_whitespace($body2)
+ 'content' => $visible_whitespace($body2)
];
$html3 = Text\BBCode::convertForUriId(0, $body2);
$results[] = [
'title' => DI::l10n()->t('PageInfo::appendToBody => BBCode::convert (raw HTML)'),
- 'content' => $this->visible_whitespace($html3)
+ 'content' => $visible_whitespace($html3)
];
$results[] = [
'title' => DI::l10n()->t('PageInfo::appendToBody => BBCode::convert'),
$diaspora = trim($request['text']);
$results[] = [
'title' => DI::l10n()->t('Source input (Diaspora format)'),
- 'content' => $this->visible_whitespace($diaspora),
+ 'content' => $visible_whitespace($diaspora),
];
$markdown = XML::unescape($diaspora);
$results[] = [
'title' => DI::l10n()->t('Source input (Markdown)'),
- 'content' => $this->visible_whitespace($markdown),
+ 'content' => $visible_whitespace($markdown),
];
$html = Text\Markdown::convert($markdown);
$results[] = [
'title' => DI::l10n()->t('Markdown::convert (raw HTML)'),
- 'content' => $this->visible_whitespace($html),
+ 'content' => $visible_whitespace($html),
];
$results[] = [
$bbcode = Text\Markdown::toBBCode($markdown);
$results[] = [
'title' => DI::l10n()->t('Markdown::toBBCode'),
- 'content' => $this->visible_whitespace($bbcode),
+ 'content' => $visible_whitespace($bbcode),
];
break;
case 'html' :
$html = trim($request['text']);
$results[] = [
'title' => DI::l10n()->t('Raw HTML input'),
- 'content' => $this->visible_whitespace($html),
+ 'content' => $visible_whitespace($html),
];
$results[] = [
$results[] = [
'title' => DI::l10n()->t('HTML Purified (raw)'),
- 'content' => $this->visible_whitespace($purified),
+ 'content' => $visible_whitespace($purified),
];
$results[] = [
'title' => DI::l10n()->t('HTML Purified (hex)'),
- 'content' => $this->visible_whitespace(bin2hex($purified)),
+ 'content' => $visible_whitespace(bin2hex($purified)),
];
$results[] = [
$bbcode = Text\HTML::toBBCode($html);
$results[] = [
'title' => DI::l10n()->t('HTML::toBBCode'),
- 'content' => $this->visible_whitespace($bbcode)
+ 'content' => $visible_whitespace($bbcode)
];
$html2 = Text\BBCode::convertForUriId(0, $bbcode);
$bbcode2plain = Text\BBCode::toPlaintext($bbcode);
$results[] = [
'title' => DI::l10n()->t('HTML::toBBCode => BBCode::toPlaintext'),
- 'content' => $this->visible_whitespace($bbcode2plain),
+ 'content' => $visible_whitespace($bbcode2plain),
];
$markdown = Text\HTML::toMarkdown($html);
$results[] = [
'title' => DI::l10n()->t('HTML::toMarkdown'),
- 'content' => $this->visible_whitespace($markdown)
+ 'content' => $visible_whitespace($markdown)
];
$text = Text\HTML::toPlaintext($html, 0);
$results[] = [
'title' => DI::l10n()->t('HTML::toPlaintext'),
- 'content' => $this->visible_whitespace($text),
+ 'content' => $visible_whitespace($text),
];
$text = Text\HTML::toPlaintext($html, 0, true);
$results[] = [
'title' => DI::l10n()->t('HTML::toPlaintext (compact)'),
- 'content' => $this->visible_whitespace($text),
+ 'content' => $visible_whitespace($text),
];
break;
case 'twitter':
$results[] = [
'title' => DI::l10n()->t('Decoded post'),
- 'content' => $this->visible_whitespace(var_export($status, true)),
+ 'content' => $visible_whitespace(var_export($status, true)),
];
$postarray = [];
$results[] = [
'title' => DI::l10n()->t('Post array before expand entities'),
- 'content' => $this->visible_whitespace(var_export($postarray, true)),
+ 'content' => $visible_whitespace(var_export($postarray, true)),
];
} else {
$results[] = [
return $o;
}
-
- private function visible_whitespace($s): string
- {
- return '<pre>' . htmlspecialchars($s) . '</pre>';
- }
}