mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-10 11:39:25 +03:00
39 lines
731 B
PHP
39 lines
731 B
PHP
|
<?php
|
||
|
|
||
|
namespace Nelmio\ApiDocBundle\Twig\Extension;
|
||
|
|
||
|
use dflydev\markdown\MarkdownExtraParser;
|
||
|
|
||
|
class MarkdownExtension extends \Twig_Extension
|
||
|
{
|
||
|
private $markdownParser;
|
||
|
|
||
|
public function __construct()
|
||
|
{
|
||
|
$this->markdownParser = new MarkdownExtraParser();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function getFilters()
|
||
|
{
|
||
|
return array(
|
||
|
'markdown' => new \Twig_Filter_Method($this, 'markdown', array('is_safe' => array('html'))),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function getName()
|
||
|
{
|
||
|
return 'nelmio_api_doc';
|
||
|
}
|
||
|
|
||
|
public function markdown($text)
|
||
|
{
|
||
|
return $this->markdownParser->transformMarkdown($text);
|
||
|
}
|
||
|
}
|