Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
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>
9
 *
10
 * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
11
 *  - (c) John MacFarlane
12
 *
13
 * For the full copyright and license information, please view the LICENSE
14
 * file that was distributed with this source code.
15
 */
16
 
17
namespace League\CommonMark\Extension\CommonMark\Renderer\Block;
18
 
19
use League\CommonMark\Extension\CommonMark\Node\Block\HtmlBlock;
20
use League\CommonMark\Node\Node;
21
use League\CommonMark\Renderer\ChildNodeRendererInterface;
22
use League\CommonMark\Renderer\NodeRendererInterface;
23
use League\CommonMark\Util\HtmlFilter;
24
use League\CommonMark\Xml\XmlNodeRendererInterface;
25
use League\Config\ConfigurationAwareInterface;
26
use League\Config\ConfigurationInterface;
27
 
28
final class HtmlBlockRenderer implements NodeRendererInterface, XmlNodeRendererInterface, ConfigurationAwareInterface
29
{
30
    /** @psalm-readonly-allow-private-mutation */
31
    private ConfigurationInterface $config;
32
 
33
    /**
34
     * @param HtmlBlock $node
35
     *
36
     * {@inheritDoc}
37
     *
38
     * @psalm-suppress MoreSpecificImplementedParamType
39
     */
40
    public function render(Node $node, ChildNodeRendererInterface $childRenderer): string
41
    {
42
        HtmlBlock::assertInstanceOf($node);
43
 
44
        $htmlInput = $this->config->get('html_input');
45
 
46
        return HtmlFilter::filter($node->getLiteral(), $htmlInput);
47
    }
48
 
49
    public function setConfiguration(ConfigurationInterface $configuration): void
50
    {
51
        $this->config = $configuration;
52
    }
53
 
54
    public function getXmlTagName(Node $node): string
55
    {
56
        return 'html_block';
57
    }
58
 
59
    /**
60
     * {@inheritDoc}
61
     */
62
    public function getXmlAttributes(Node $node): array
63
    {
64
        return [];
65
    }
66
}