Update dependencies, min PHP 7.2
This commit is contained in:
@ -3,8 +3,9 @@
|
||||
use League\CommonMark\DocParser;
|
||||
use League\CommonMark\Environment;
|
||||
use League\CommonMark\HtmlRenderer;
|
||||
use League\CommonMark\Ext\Table\TableExtension;
|
||||
use League\CommonMark\Inline\Element as InlineElement;
|
||||
use Todaymade\Daux\Config;
|
||||
use Webuni\CommonMark\TableExtension\TableExtension;
|
||||
|
||||
class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
|
||||
{
|
||||
@ -39,6 +40,6 @@ class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
|
||||
|
||||
protected function extendEnvironment(Environment $environment, Config $config)
|
||||
{
|
||||
$environment->addInlineRenderer('Link', $this->getLinkRenderer($environment));
|
||||
$environment->addInlineRenderer(InlineElement\Link::class, $this->getLinkRenderer($environment));
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,15 @@ use League\CommonMark\ElementRendererInterface;
|
||||
use League\CommonMark\HtmlElement;
|
||||
use League\CommonMark\Inline\Element\AbstractInline;
|
||||
use League\CommonMark\Inline\Element\Link;
|
||||
use League\CommonMark\Inline\Renderer\InlineRendererInterface;
|
||||
use League\CommonMark\Util\ConfigurationAwareInterface;
|
||||
use League\CommonMark\Util\ConfigurationInterface;
|
||||
use Todaymade\Daux\Config;
|
||||
use Todaymade\Daux\DauxHelper;
|
||||
use Todaymade\Daux\Exception\LinkNotFoundException;
|
||||
use Todaymade\Daux\Tree\Entry;
|
||||
|
||||
class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
||||
class LinkRenderer implements InlineRendererInterface, ConfigurationAwareInterface
|
||||
{
|
||||
/**
|
||||
* @var Config
|
||||
@ -66,6 +69,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
||||
protected function isExternalUrl($url)
|
||||
{
|
||||
return preg_match('#^(?:[a-z]+:)?//|^mailto:#', $url);
|
||||
$this->parent = new \League\CommonMark\Inline\Renderer\LinkRenderer();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,7 +91,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
||||
);
|
||||
}
|
||||
|
||||
$element = parent::render($inline, $htmlRenderer);
|
||||
$element = $this->parent->render($inline, $htmlRenderer);
|
||||
|
||||
$url = $inline->getUrl();
|
||||
|
||||
@ -116,7 +120,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
||||
$url = DauxHelper::getRelativePath($this->daux->getCurrentPage()->getUrl(), $file->getUrl());
|
||||
} catch (LinkNotFoundException $e) {
|
||||
|
||||
|
||||
|
||||
|
||||
// For some reason, the filename could contain a # and thus the link needs to resolve to that.
|
||||
try {
|
||||
@ -148,4 +152,13 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigurationInterface $configuration
|
||||
*/
|
||||
public function setConfiguration(ConfigurationInterface $configuration)
|
||||
{
|
||||
$this->config = $configuration;
|
||||
$this->parent->setConfiguration($configuration);
|
||||
}
|
||||
}
|
||||
|
@ -12,17 +12,7 @@ class TableOfContents extends AbstractBlock
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canContain(AbstractBlock $block)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if block type can accept lines of text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function acceptsLines()
|
||||
public function canContain(AbstractBlock $block): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -32,7 +22,7 @@ class TableOfContents extends AbstractBlock
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCode()
|
||||
public function isCode(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -42,7 +32,7 @@ class TableOfContents extends AbstractBlock
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matchesNextLine(Cursor $cursor)
|
||||
public function matchesNextLine(Cursor $cursor): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php namespace Todaymade\Daux\ContentTypes\Markdown;
|
||||
|
||||
use League\CommonMark\Block\Parser\AbstractBlockParser;
|
||||
use League\CommonMark\Block\Parser\BlockParserInterface;
|
||||
use League\CommonMark\ContextInterface;
|
||||
use League\CommonMark\Cursor;
|
||||
|
||||
class TableOfContentsParser extends AbstractBlockParser
|
||||
class TableOfContentsParser implements BlockParserInterface
|
||||
{
|
||||
/**
|
||||
* @param ContextInterface $context
|
||||
@ -12,7 +12,7 @@ class TableOfContentsParser extends AbstractBlockParser
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function parse(ContextInterface $context, Cursor $cursor)
|
||||
public function parse(ContextInterface $context, Cursor $cursor): bool
|
||||
{
|
||||
if ($cursor->isIndented()) {
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user