|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This is part of the webuni/commonmark-table-extension package. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Martin Hasoň <[email protected]> |
|
9
|
|
|
* (c) Webuni s.r.o. <[email protected]> |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
12
|
|
|
* file that was distributed with this source code. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Webuni\CommonMark\TableExtension; |
|
16
|
|
|
|
|
17
|
|
|
use League\CommonMark\Block\Element\AbstractBlock; |
|
18
|
|
|
use League\CommonMark\ContextInterface; |
|
19
|
|
|
use League\CommonMark\Cursor; |
|
20
|
|
|
use League\CommonMark\Node\Node; |
|
21
|
|
|
|
|
22
|
|
|
class TableRows extends AbstractBlock |
|
23
|
|
|
{ |
|
24
|
|
|
const TYPE_HEAD = 'thead'; |
|
25
|
|
|
const TYPE_BODY = 'tbody'; |
|
26
|
|
|
|
|
27
|
|
|
public $type = self::TYPE_BODY; |
|
28
|
|
|
|
|
29
|
|
|
public function __construct(string $type = self::TYPE_BODY) |
|
30
|
|
|
{ |
|
31
|
|
|
parent::__construct(); |
|
32
|
|
|
$this->type = $type; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function isHead(): bool |
|
36
|
|
|
{ |
|
37
|
|
|
return self::TYPE_HEAD === $this->type; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function isBody(): bool |
|
41
|
|
|
{ |
|
42
|
|
|
return self::TYPE_BODY === $this->type; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function canContain(AbstractBlock $block): bool |
|
46
|
|
|
{ |
|
47
|
|
|
return $block instanceof TableRow; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function acceptsLines(): bool |
|
51
|
|
|
{ |
|
52
|
|
|
return false; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function isCode(): bool |
|
56
|
|
|
{ |
|
57
|
|
|
return false; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function matchesNextLine(Cursor $cursor): bool |
|
61
|
|
|
{ |
|
62
|
|
|
return false; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function handleRemainingContents(ContextInterface $context, Cursor $cursor): void |
|
66
|
|
|
{ |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @return AbstractBlock[] |
|
71
|
|
|
*/ |
|
72
|
|
|
public function children(): array |
|
73
|
|
|
{ |
|
74
|
|
|
return array_filter(parent::children(), function (Node $child): bool { return $child instanceof AbstractBlock; }); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|