mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
39 lines
708 B
PHP
39 lines
708 B
PHP
<?php
|
|
|
|
namespace Nelmio\ApiDocBundle\Twig\Extension;
|
|
|
|
use Michelf\MarkdownExtra;
|
|
|
|
class MarkdownExtension extends \Twig_Extension
|
|
{
|
|
private $markdownParser;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->markdownParser = new MarkdownExtra();
|
|
}
|
|
|
|
/**
|
|
* {@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->transform($text);
|
|
}
|
|
}
|