daux.io/libs/Format/Base/CommonMark/CommonMarkConverter.php

39 regels
1.1 KiB
PHP

2015-06-29 16:16:39 +02:00
<?php namespace Todaymade\Daux\Format\Base\CommonMark;
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);
if (array_key_exists('processor_instance', $config['daux'])) {
$config['daux']['processor_instance']->extendCommonMarkEnvironment($environment);
}
2015-07-17 18:34:00 +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));
}
}