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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getFilters()
|
|
|
|
{
|
|
|
|
return array(
|
2022-12-01 16:52:52 +03:00
|
|
|
new \Twig\TwigFilter('extra_markdown', array($this, 'markdown'), array('is_safe' => array('html'))),
|
2012-07-20 16:59:59 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|