2015-06-29 16:16:39 +02:00
|
|
|
<?php namespace Todaymade\Daux\Format\Base\CommonMark;
|
2015-05-22 14:48:09 +02:00
|
|
|
|
|
|
|
use League\CommonMark\DocParser;
|
|
|
|
use League\CommonMark\Environment;
|
|
|
|
use League\CommonMark\HtmlRenderer;
|
|
|
|
|
|
|
|
class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Create a new commonmark converter instance.
|
|
|
|
*
|
|
|
|
* @param array $config
|
|
|
|
*/
|
|
|
|
public function __construct(array $config = array())
|
|
|
|
{
|
|
|
|
$environment = Environment::createCommonMarkEnvironment();
|
|
|
|
$environment->mergeConfig($config);
|
|
|
|
|
2015-06-29 16:16:39 +02:00
|
|
|
$this->extendEnvironment($environment);
|
2015-05-22 14:48:09 +02:00
|
|
|
|
|
|
|
$this->docParser = new DocParser($environment);
|
|
|
|
$this->htmlRenderer = new HtmlRenderer($environment);
|
|
|
|
}
|
2015-06-29 16:16:39 +02:00
|
|
|
|
|
|
|
protected function getLinkRenderer(Environment $environment)
|
|
|
|
{
|
|
|
|
return new LinkRenderer($environment->getConfig('daux'));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function extendEnvironment(Environment $environment)
|
|
|
|
{
|
|
|
|
$environment->addInlineRenderer('Link', $this->getLinkRenderer($environment));
|
|
|
|
}
|
2015-05-22 14:48:09 +02:00
|
|
|
}
|