| 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\Heading;
|
|
|
17 |
use League\CommonMark\Parser\Block\AbstractBlockContinueParser;
|
|
|
18 |
use League\CommonMark\Parser\Block\BlockContinue;
|
|
|
19 |
use League\CommonMark\Parser\Block\BlockContinueParserInterface;
|
|
|
20 |
use League\CommonMark\Parser\Block\BlockContinueParserWithInlinesInterface;
|
|
|
21 |
use League\CommonMark\Parser\Cursor;
|
|
|
22 |
use League\CommonMark\Parser\InlineParserEngineInterface;
|
|
|
23 |
|
|
|
24 |
final class HeadingParser extends AbstractBlockContinueParser implements BlockContinueParserWithInlinesInterface
|
|
|
25 |
{
|
|
|
26 |
/** @psalm-readonly */
|
|
|
27 |
private Heading $block;
|
|
|
28 |
|
|
|
29 |
private string $content;
|
|
|
30 |
|
|
|
31 |
public function __construct(int $level, string $content)
|
|
|
32 |
{
|
|
|
33 |
$this->block = new Heading($level);
|
|
|
34 |
$this->content = $content;
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
public function getBlock(): Heading
|
|
|
38 |
{
|
|
|
39 |
return $this->block;
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
public function tryContinue(Cursor $cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue
|
|
|
43 |
{
|
|
|
44 |
return BlockContinue::none();
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
public function parseInlines(InlineParserEngineInterface $inlineParser): void
|
|
|
48 |
{
|
|
|
49 |
$inlineParser->parse($this->content, $this->block);
|
|
|
50 |
}
|
|
|
51 |
}
|