mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-04-09 04:02:06 +00:00
Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
|
10ee31bdaa | ||
|
6946e8bdc9 |
1 changed files with 6 additions and 5 deletions
|
@ -4,29 +4,30 @@ namespace Nelmio\ApiDocBundle\Twig\Extension;
|
||||||
|
|
||||||
use Michelf\MarkdownExtra;
|
use Michelf\MarkdownExtra;
|
||||||
use Twig\Extension\AbstractExtension;
|
use Twig\Extension\AbstractExtension;
|
||||||
|
use Twig\TwigFilter;
|
||||||
|
|
||||||
class MarkdownExtension extends AbstractExtension
|
class MarkdownExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
protected $markdownParser;
|
private MarkdownExtra $markdownParser;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->markdownParser = new MarkdownExtra();
|
$this->markdownParser = new MarkdownExtra();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilters()
|
public function getFilters(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new \Twig\TwigFilter('extra_markdown', [$this, 'markdown'], ['is_safe' => ['html']]),
|
new TwigFilter('extra_markdown', [$this, 'markdown'], ['is_safe' => ['html']]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return 'nelmio_api_doc';
|
return 'nelmio_api_doc';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function markdown($text)
|
public function markdown($text): string
|
||||||
{
|
{
|
||||||
return $this->markdownParser->transform($text);
|
return $this->markdownParser->transform($text);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue