| 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\Parser\Block;
|
|
|
18 |
|
|
|
19 |
use League\CommonMark\Node\Block\AbstractBlock;
|
|
|
20 |
use League\CommonMark\Parser\Cursor;
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* Interface for a block continuation parser
|
|
|
24 |
*
|
|
|
25 |
* A block continue parser can only handle a single block instance. The current block being parsed is stored within this parser and
|
|
|
26 |
* can be returned once parsing has completed. If you need to parse multiple block continuations, instantiate a new parser for each one.
|
|
|
27 |
*/
|
|
|
28 |
interface BlockContinueParserInterface
|
|
|
29 |
{
|
|
|
30 |
/**
|
|
|
31 |
* Return the current block being parsed by this parser
|
|
|
32 |
*/
|
|
|
33 |
public function getBlock(): AbstractBlock;
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
* Return whether we are parsing a container block
|
|
|
37 |
*/
|
|
|
38 |
public function isContainer(): bool;
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* Return whether we are interested in possibly lazily parsing any subsequent lines
|
|
|
42 |
*/
|
|
|
43 |
public function canHaveLazyContinuationLines(): bool;
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
* Determine whether the current block being parsed can contain the given child block
|
|
|
47 |
*/
|
|
|
48 |
public function canContain(AbstractBlock $childBlock): bool;
|
|
|
49 |
|
|
|
50 |
/**
|
|
|
51 |
* Attempt to parse the given line
|
|
|
52 |
*/
|
|
|
53 |
public function tryContinue(Cursor $cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue;
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
* Add the given line of text to the current block
|
|
|
57 |
*/
|
|
|
58 |
public function addLine(string $line): void;
|
|
|
59 |
|
|
|
60 |
/**
|
|
|
61 |
* Close and finalize the current block
|
|
|
62 |
*/
|
|
|
63 |
public function closeBlock(): void;
|
|
|
64 |
}
|