2012-07-20 16:59:59 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Nelmio\ApiDocBundle\Twig\Extension;
|
|
|
|
|
2014-02-19 12:55:16 +01:00
|
|
|
use Michelf\MarkdownExtra;
|
2022-12-01 16:52:52 +03:00
|
|
|
use Twig\Extension\AbstractExtension;
|
2012-07-20 16:59:59 +02:00
|
|
|
|
2022-12-01 16:52:52 +03:00
|
|
|
class MarkdownExtension extends AbstractExtension
|
2012-07-20 16:59:59 +02:00
|
|
|
{
|
2016-03-19 15:07:00 +01:00
|
|
|
protected $markdownParser;
|
2012-07-20 16:59:59 +02:00
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
2014-02-19 12:55:16 +01:00
|
|
|
$this->markdownParser = new MarkdownExtra();
|
2012-07-20 16:59:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getFilters()
|
|
|
|
{
|
2024-10-01 15:54:04 +03:00
|
|
|
return [
|
|
|
|
new \Twig\TwigFilter('extra_markdown', [$this, 'markdown'], ['is_safe' => ['html']]),
|
|
|
|
];
|
2012-07-20 16:59:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return 'nelmio_api_doc';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function markdown($text)
|
|
|
|
{
|
2014-02-19 12:55:16 +01:00
|
|
|
return $this->markdownParser->transform($text);
|
2012-07-20 16:59:59 +02:00
|
|
|
}
|
|
|
|
}
|