X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c429cf78187e80deb63982a282a1c6889f30291a..refs/pull/5725/head:/app/Entities/Tools/Markdown/CustomStrikethroughRenderer.php diff --git a/app/Entities/Tools/Markdown/CustomStrikethroughRenderer.php b/app/Entities/Tools/Markdown/CustomStrikethroughRenderer.php index ca9f434af..01b09377b 100644 --- a/app/Entities/Tools/Markdown/CustomStrikethroughRenderer.php +++ b/app/Entities/Tools/Markdown/CustomStrikethroughRenderer.php @@ -2,25 +2,23 @@ namespace BookStack\Entities\Tools\Markdown; -use League\CommonMark\ElementRendererInterface; use League\CommonMark\Extension\Strikethrough\Strikethrough; -use League\CommonMark\HtmlElement; -use League\CommonMark\Inline\Element\AbstractInline; -use League\CommonMark\Inline\Renderer\InlineRendererInterface; +use League\CommonMark\Node\Node; +use League\CommonMark\Renderer\ChildNodeRendererInterface; +use League\CommonMark\Renderer\NodeRendererInterface; +use League\CommonMark\Util\HtmlElement; /** * This is a somewhat clone of the League\CommonMark\Extension\Strikethrough\StrikethroughRender * class but modified slightly to use HTML tags instead of in order to * match front-end markdown-it rendering. */ -class CustomStrikethroughRenderer implements InlineRendererInterface +class CustomStrikethroughRenderer implements NodeRendererInterface { - public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer) + public function render(Node $node, ChildNodeRendererInterface $childRenderer) { - if (!($inline instanceof Strikethrough)) { - throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline)); - } + Strikethrough::assertInstanceOf($node); - return new HtmlElement('s', $inline->getData('attributes', []), $htmlRenderer->renderInlines($inline->children())); + return new HtmlElement('s', $node->data->get('attributes'), $childRenderer->renderNodes($node->children())); } }