| 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 |
* 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\CommonMark\Parser\Block;
|
|
|
15 |
|
|
|
16 |
use League\CommonMark\Extension\CommonMark\Node\Block\BlockQuote;
|
|
|
17 |
use League\CommonMark\Node\Block\AbstractBlock;
|
|
|
18 |
use League\CommonMark\Parser\Block\AbstractBlockContinueParser;
|
|
|
19 |
use League\CommonMark\Parser\Block\BlockContinue;
|
|
|
20 |
use League\CommonMark\Parser\Block\BlockContinueParserInterface;
|
|
|
21 |
use League\CommonMark\Parser\Cursor;
|
|
|
22 |
|
|
|
23 |
final class BlockQuoteParser extends AbstractBlockContinueParser
|
|
|
24 |
{
|
|
|
25 |
/** @psalm-readonly */
|
|
|
26 |
private BlockQuote $block;
|
|
|
27 |
|
|
|
28 |
public function __construct()
|
|
|
29 |
{
|
|
|
30 |
$this->block = new BlockQuote();
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
public function getBlock(): BlockQuote
|
|
|
34 |
{
|
|
|
35 |
return $this->block;
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
public function isContainer(): bool
|
|
|
39 |
{
|
|
|
40 |
return true;
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
public function canContain(AbstractBlock $childBlock): bool
|
|
|
44 |
{
|
|
|
45 |
return true;
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
public function tryContinue(Cursor $cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue
|
|
|
49 |
{
|
|
|
50 |
if (! $cursor->isIndented() && $cursor->getNextNonSpaceCharacter() === '>') {
|
|
|
51 |
$cursor->advanceToNextNonSpaceOrTab();
|
|
|
52 |
$cursor->advanceBy(1);
|
|
|
53 |
$cursor->advanceBySpaceOrTab();
|
|
|
54 |
|
|
|
55 |
return BlockContinue::at($cursor);
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
return BlockContinue::none();
|
|
|
59 |
}
|
|
|
60 |
}
|