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;
|
2012-07-20 16:59:59 +02:00
|
|
|
|
|
|
|
class MarkdownExtension extends \Twig_Extension
|
|
|
|
{
|
|
|
|
private $markdownParser;
|
|
|
|
|
|
|
|
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(
|
2015-08-28 10:50:28 +02:00
|
|
|
new \Twig_SimpleFilter('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
|
|
|
}
|
|
|
|
}
|