mirror of
https://github.com/KnpLabs/KnpMarkdownBundle.git
synced 2024-05-04 14:43:17 +02:00
3c541b580b
Refactored way how parsers are initialized, and allow to select parser while rendering Interface `MarkdownParserInterface` method name was changed from `#transform($text)` to `#transformMarkdown($text)`
31 lines
567 B
PHP
31 lines
567 B
PHP
<?php
|
|
|
|
namespace Knp\Bundle\MarkdownBundle\Parser;
|
|
|
|
use Knp\Bundle\MarkdownBundle\MarkdownParserInterface;
|
|
|
|
use Sundown\Markdown;
|
|
|
|
/**
|
|
* SundownParser
|
|
*
|
|
* This class wraps the original Sundown parser to implement the KnpMardownBundle interface
|
|
*/
|
|
class SundownParser implements MarkdownParserInterface
|
|
{
|
|
private $parser;
|
|
|
|
public function __construct(Markdown $parser)
|
|
{
|
|
$this->parser = $parser;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function transformMarkdown($text)
|
|
{
|
|
return $this->parser->render($text);
|
|
}
|
|
}
|