parent
245f392a9d
commit
1ac5557187
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2019 Icinga GmbH | GPLv2+ */
|
||||
|
||||
namespace Icinga\Web\Helper;
|
||||
|
||||
use Parsedown;
|
||||
|
||||
class Markdown
|
||||
{
|
||||
public static function text($content)
|
||||
{
|
||||
require_once 'Parsedown/Parsedown.php';
|
||||
return HtmlPurifier::process(Parsedown::instance()->text($content));
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
namespace Icinga\Web\View;
|
||||
|
||||
use Icinga\Util\StringHelper;
|
||||
use Icinga\Web\Helper\Markdown;
|
||||
|
||||
$this->addHelperFunction('ellipsis', function ($string, $maxLength, $ellipsis = '...') {
|
||||
return StringHelper::ellipsis($string, $maxLength, $ellipsis);
|
||||
|
@ -12,3 +13,7 @@ $this->addHelperFunction('ellipsis', function ($string, $maxLength, $ellipsis =
|
|||
$this->addHelperFunction('nl2br', function ($string) {
|
||||
return nl2br(str_replace(array('\r\n', '\r', '\n'), '<br>', $string), false);
|
||||
});
|
||||
|
||||
$this->addHelperFunction('markdown', function ($content) {
|
||||
return Markdown::text($content);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue