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\Block\Element\InlineContainerInterface; |
19
|
|
|
use League\CommonMark\ContextInterface; |
20
|
|
|
use League\CommonMark\Cursor; |
21
|
|
|
use League\CommonMark\Inline\Element\AbstractInline; |
22
|
|
|
use League\CommonMark\Node\Node; |
23
|
|
|
|
24
|
|
|
class TableCell extends AbstractBlock implements InlineContainerInterface |
25
|
|
|
{ |
26
|
|
|
const TYPE_HEAD = 'th'; |
27
|
|
|
const TYPE_BODY = 'td'; |
28
|
|
|
|
29
|
|
|
const ALIGN_LEFT = 'left'; |
30
|
|
|
const ALIGN_RIGHT = 'right'; |
31
|
|
|
const ALIGN_CENTER = 'center'; |
32
|
|
|
|
33
|
|
|
public $type = self::TYPE_BODY; |
34
|
|
|
public $align; |
35
|
|
|
|
36
|
|
|
public function __construct(string $string = '', string $type = self::TYPE_BODY, string $align = null) |
37
|
|
|
{ |
38
|
|
|
parent::__construct(); |
39
|
|
|
$this->finalStringContents = $string; |
40
|
|
|
$this->type = $type; |
41
|
|
|
$this->align = $align; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function canContain(AbstractBlock $block): bool |
45
|
|
|
{ |
46
|
|
|
return false; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function acceptsLines(): bool |
50
|
|
|
{ |
51
|
|
|
return false; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function isCode(): bool |
55
|
|
|
{ |
56
|
|
|
return false; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function matchesNextLine(Cursor $cursor): bool |
60
|
|
|
{ |
61
|
|
|
return false; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function handleRemainingContents(ContextInterface $context, Cursor $cursor): void |
65
|
|
|
{ |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return AbstractInline[] |
70
|
|
|
*/ |
71
|
|
|
public function children(): array |
72
|
|
|
{ |
73
|
|
|
return array_filter(parent::children(), function (Node $child): bool { return $child instanceof AbstractInline; }); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|