| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
/*
|
|
|
6 |
* This file is part of the league/commonmark package.
|
|
|
7 |
*
|
|
|
8 |
* (c) Colin O'Dell <colinodell@gmail.com> and uAfrica.com (http://uafrica.com)
|
|
|
9 |
*
|
|
|
10 |
* For the full copyright and license information, please view the LICENSE
|
|
|
11 |
* file that was distributed with this source code.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
namespace League\CommonMark\Extension\Strikethrough;
|
|
|
15 |
|
|
|
16 |
use League\CommonMark\Node\Node;
|
|
|
17 |
use League\CommonMark\Renderer\ChildNodeRendererInterface;
|
|
|
18 |
use League\CommonMark\Renderer\NodeRendererInterface;
|
|
|
19 |
use League\CommonMark\Util\HtmlElement;
|
|
|
20 |
use League\CommonMark\Xml\XmlNodeRendererInterface;
|
|
|
21 |
|
|
|
22 |
final class StrikethroughRenderer implements NodeRendererInterface, XmlNodeRendererInterface
|
|
|
23 |
{
|
|
|
24 |
/**
|
|
|
25 |
* @param Strikethrough $node
|
|
|
26 |
*
|
|
|
27 |
* {@inheritDoc}
|
|
|
28 |
*
|
|
|
29 |
* @psalm-suppress MoreSpecificImplementedParamType
|
|
|
30 |
*/
|
|
|
31 |
public function render(Node $node, ChildNodeRendererInterface $childRenderer): \Stringable
|
|
|
32 |
{
|
|
|
33 |
Strikethrough::assertInstanceOf($node);
|
|
|
34 |
|
|
|
35 |
return new HtmlElement('del', $node->data->get('attributes'), $childRenderer->renderNodes($node->children()));
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
public function getXmlTagName(Node $node): string
|
|
|
39 |
{
|
|
|
40 |
return 'strikethrough';
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
/**
|
|
|
44 |
* {@inheritDoc}
|
|
|
45 |
*/
|
|
|
46 |
public function getXmlAttributes(Node $node): array
|
|
|
47 |
{
|
|
|
48 |
return [];
|
|
|
49 |
}
|
|
|
50 |
}
|