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