mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
parent
245f392a9d
commit
1ac5557187
15
library/Icinga/Web/Helper/Markdown.php
Normal file
15
library/Icinga/Web/Helper/Markdown.php
Normal file
@ -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;
|
namespace Icinga\Web\View;
|
||||||
|
|
||||||
use Icinga\Util\StringHelper;
|
use Icinga\Util\StringHelper;
|
||||||
|
use Icinga\Web\Helper\Markdown;
|
||||||
|
|
||||||
$this->addHelperFunction('ellipsis', function ($string, $maxLength, $ellipsis = '...') {
|
$this->addHelperFunction('ellipsis', function ($string, $maxLength, $ellipsis = '...') {
|
||||||
return StringHelper::ellipsis($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) {
|
$this->addHelperFunction('nl2br', function ($string) {
|
||||||
return nl2br(str_replace(array('\r\n', '\r', '\n'), '<br>', $string), false);
|
return nl2br(str_replace(array('\r\n', '\r', '\n'), '<br>', $string), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$this->addHelperFunction('markdown', function ($content) {
|
||||||
|
return Markdown::text($content);
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user