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\Renderer\Block;
18
 
19
use League\CommonMark\Node\Block\Document;
20
use League\CommonMark\Node\Node;
21
use League\CommonMark\Renderer\ChildNodeRendererInterface;
22
use League\CommonMark\Renderer\NodeRendererInterface;
23
use League\CommonMark\Xml\XmlNodeRendererInterface;
24
 
25
final class DocumentRenderer implements NodeRendererInterface, XmlNodeRendererInterface
26
{
27
    /**
28
     * @param Document $node
29
     *
30
     * {@inheritDoc}
31
     *
32
     * @psalm-suppress MoreSpecificImplementedParamType
33
     */
34
    public function render(Node $node, ChildNodeRendererInterface $childRenderer): string
35
    {
36
        Document::assertInstanceOf($node);
37
 
38
        $wholeDoc = $childRenderer->renderNodes($node->children());
39
 
40
        return $wholeDoc === '' ? '' : $wholeDoc . "\n";
41
    }
42
 
43
    public function getXmlTagName(Node $node): string
44
    {
45
        return 'document';
46
    }
47
 
48
    /**
49
     * {@inheritDoc}
50
     */
51
    public function getXmlAttributes(Node $node): array
52
    {
53
        return [
54
            'xmlns' => 'http://commonmark.org/xml/1.0',
55
        ];
56
    }
57
}