1 <?php namespace BookStack\Entities\Tools\Markdown;
3 use League\CommonMark\ElementRendererInterface;
4 use League\CommonMark\Extension\Strikethrough\Strikethrough;
5 use League\CommonMark\HtmlElement;
6 use League\CommonMark\Inline\Element\AbstractInline;
7 use League\CommonMark\Inline\Renderer\InlineRendererInterface;
10 * This is a somewhat clone of the League\CommonMark\Extension\Strikethrough\StrikethroughRender
11 * class but modified slightly to use <s> HTML tags instead of <del> in order to
12 * match front-end markdown-it rendering.
14 class CustomStrikethroughRenderer implements InlineRendererInterface
16 public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
18 if (!($inline instanceof Strikethrough)) {
19 throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
22 return new HtmlElement('s', $inline->getData('attributes', []), $htmlRenderer->renderInlines($inline->children()));