2021-06-26 11:23:15 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Entities\Tools\Markdown;
|
2021-01-10 18:01:11 -05:00
|
|
|
|
|
|
|
use League\CommonMark\Extension\Strikethrough\Strikethrough;
|
2023-02-06 15:00:44 -05:00
|
|
|
use League\CommonMark\Node\Node;
|
|
|
|
use League\CommonMark\Renderer\ChildNodeRendererInterface;
|
|
|
|
use League\CommonMark\Renderer\NodeRendererInterface;
|
|
|
|
use League\CommonMark\Util\HtmlElement;
|
2021-01-10 18:01:11 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a somewhat clone of the League\CommonMark\Extension\Strikethrough\StrikethroughRender
|
|
|
|
* class but modified slightly to use <s> HTML tags instead of <del> in order to
|
|
|
|
* match front-end markdown-it rendering.
|
|
|
|
*/
|
2023-02-06 15:00:44 -05:00
|
|
|
class CustomStrikethroughRenderer implements NodeRendererInterface
|
2021-01-10 18:01:11 -05:00
|
|
|
{
|
2023-02-06 15:00:44 -05:00
|
|
|
public function render(Node $node, ChildNodeRendererInterface $childRenderer)
|
2021-01-10 18:01:11 -05:00
|
|
|
{
|
2023-02-06 15:00:44 -05:00
|
|
|
Strikethrough::assertInstanceOf($node);
|
2021-01-10 18:01:11 -05:00
|
|
|
|
2023-02-06 15:00:44 -05:00
|
|
|
return new HtmlElement('s', $node->data->get('attributes'), $childRenderer->renderNodes($node->children()));
|
2021-01-10 18:01:11 -05:00
|
|
|
}
|
2021-03-07 17:24:05 -05:00
|
|
|
}
|