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
|
|
|
|
2015-07-19 00:55:57 +02:00
|
|
|
if (array_key_exists('processor_instance', $config['daux'])) {
|
|
|
|
$config['daux']['processor_instance']->extendCommonMarkEnvironment($environment);
|
|
|
|
}
|
2015-07-17 18:34:00 +02:00
|
|
|
|
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)
|
|
|
|
{
|
2015-07-17 23:38:06 +02:00
|
|
|
return new LinkRenderer($environment->getConfig('daux'));
|
2015-06-29 16:16:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function extendEnvironment(Environment $environment)
|
|
|
|
{
|
|
|
|
$environment->addInlineRenderer('Link', $this->getLinkRenderer($environment));
|
|
|
|
}
|
2015-05-22 14:48:09 +02:00
|
|
|
}
|