mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
39 lines
737 B
PHP
39 lines
737 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(
|
|
'extra_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);
|
|
}
|
|
}
|