mirror of
https://github.com/KnpLabs/KnpMarkdownBundle.git
synced 2024-06-08 17:02:11 +02:00
34 lines
675 B
PHP
34 lines
675 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;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Converts text to html using markdown rules
|
||
|
*
|
||
|
* @param string $text plain text
|
||
|
*
|
||
|
* @return string rendered html
|
||
|
*/
|
||
|
public function transform($text)
|
||
|
{
|
||
|
return $this->parser->render($text);
|
||
|
}
|
||
|
}
|