Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <colinodell@gmail.com>
7
 * (c) Rezo Zero / Ambroise Maupate
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
 
13
declare(strict_types=1);
14
 
15
namespace League\CommonMark\Extension\Footnote\Renderer;
16
 
17
use League\CommonMark\Extension\Footnote\Node\FootnoteContainer;
18
use League\CommonMark\Node\Node;
19
use League\CommonMark\Renderer\ChildNodeRendererInterface;
20
use League\CommonMark\Renderer\NodeRendererInterface;
21
use League\CommonMark\Util\HtmlElement;
22
use League\CommonMark\Xml\XmlNodeRendererInterface;
23
use League\Config\ConfigurationAwareInterface;
24
use League\Config\ConfigurationInterface;
25
 
26
final class FootnoteContainerRenderer implements NodeRendererInterface, XmlNodeRendererInterface, ConfigurationAwareInterface
27
{
28
    private ConfigurationInterface $config;
29
 
30
    /**
31
     * @param FootnoteContainer $node
32
     *
33
     * {@inheritDoc}
34
     *
35
     * @psalm-suppress MoreSpecificImplementedParamType
36
     */
37
    public function render(Node $node, ChildNodeRendererInterface $childRenderer): \Stringable
38
    {
39
        FootnoteContainer::assertInstanceOf($node);
40
 
41
        $attrs = $node->data->getData('attributes');
42
 
43
        $attrs->append('class', $this->config->get('footnote/container_class'));
44
        $attrs->set('role', 'doc-endnotes');
45
 
46
        $contents = new HtmlElement('ol', [], $childRenderer->renderNodes($node->children()));
47
        if ($this->config->get('footnote/container_add_hr')) {
48
            $contents = [new HtmlElement('hr', [], null, true), $contents];
49
        }
50
 
51
        return new HtmlElement('div', $attrs->export(), $contents);
52
    }
53
 
54
    public function setConfiguration(ConfigurationInterface $configuration): void
55
    {
56
        $this->config = $configuration;
57
    }
58
 
59
    public function getXmlTagName(Node $node): string
60
    {
61
        return 'footnote_container';
62
    }
63
 
64
    /**
65
     * @return array<string, scalar>
66
     */
67
    public function getXmlAttributes(Node $node): array
68
    {
69
        return [];
70
    }
71
}