2020-03-31 11:32:29 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
|
|
|
|
|
|
2021-08-20 10:39:29 -04:00
|
|
|
namespace Icinga\Module\Icingadb\Widget;
|
2020-03-31 11:32:29 -04:00
|
|
|
|
|
|
|
|
use Icinga\Web\Helper\Markdown;
|
|
|
|
|
use ipl\Html\BaseHtmlElement;
|
|
|
|
|
use ipl\Html\DeferredText;
|
|
|
|
|
|
|
|
|
|
class MarkdownText extends BaseHtmlElement
|
|
|
|
|
{
|
|
|
|
|
protected $tag = 'section';
|
|
|
|
|
|
|
|
|
|
protected $defaultAttributes = ['class' => 'markdown'];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* MarkdownText constructor.
|
|
|
|
|
*
|
|
|
|
|
* @param string $text
|
|
|
|
|
*/
|
2021-09-22 04:21:15 -04:00
|
|
|
public function __construct(string $text)
|
2020-03-31 11:32:29 -04:00
|
|
|
{
|
|
|
|
|
$this->add((new DeferredText(function () use ($text) {
|
|
|
|
|
return Markdown::text($text);
|
|
|
|
|
}))->setEscaped(true));
|
|
|
|
|
}
|
|
|
|
|
}
|