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\Parser;
16
 
17
use League\CommonMark\Extension\Footnote\Node\Footnote;
18
use League\CommonMark\Node\Block\AbstractBlock;
19
use League\CommonMark\Parser\Block\AbstractBlockContinueParser;
20
use League\CommonMark\Parser\Block\BlockContinue;
21
use League\CommonMark\Parser\Block\BlockContinueParserInterface;
22
use League\CommonMark\Parser\Cursor;
23
use League\CommonMark\Reference\ReferenceInterface;
24
 
25
final class FootnoteParser extends AbstractBlockContinueParser
26
{
27
    /** @psalm-readonly */
28
    private Footnote $block;
29
 
30
    /** @psalm-readonly-allow-private-mutation */
31
    private ?int $indentation = null;
32
 
33
    public function __construct(ReferenceInterface $reference)
34
    {
35
        $this->block = new Footnote($reference);
36
    }
37
 
38
    public function getBlock(): Footnote
39
    {
40
        return $this->block;
41
    }
42
 
43
    public function tryContinue(Cursor $cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue
44
    {
45
        if ($cursor->isBlank()) {
46
            return BlockContinue::at($cursor);
47
        }
48
 
49
        if ($cursor->isIndented()) {
50
            $this->indentation ??= $cursor->getIndent();
51
            $cursor->advanceBy($this->indentation, true);
52
 
53
            return BlockContinue::at($cursor);
54
        }
55
 
56
        return BlockContinue::none();
57
    }
58
 
59
    public function isContainer(): bool
60
    {
61
        return true;
62
    }
63
 
64
    public function canContain(AbstractBlock $childBlock): bool
65
    {
66
        return true;
67
    }
68
}