1 | <?php |
||
20 | class Heading extends AbstractBlock implements InlineContainerInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var int |
||
24 | */ |
||
25 | protected $level; |
||
26 | |||
27 | /** |
||
28 | * @param int $level |
||
29 | * @param string|string[] $contents |
||
30 | */ |
||
31 | 141 | public function __construct($level, $contents) |
|
32 | { |
||
33 | 141 | parent::__construct(); |
|
34 | |||
35 | 141 | $this->level = $level; |
|
36 | |||
37 | 141 | if (!is_array($contents)) { |
|
38 | 99 | $contents = [$contents]; |
|
39 | } |
||
40 | |||
41 | 141 | foreach ($contents as $line) { |
|
42 | 141 | $this->addLine($line); |
|
43 | } |
||
44 | 141 | } |
|
45 | |||
46 | /** |
||
47 | * @return int |
||
48 | */ |
||
49 | 141 | public function getLevel() |
|
53 | |||
54 | 123 | public function finalize(ContextInterface $context, $endLineNumber) |
|
60 | |||
61 | /** |
||
62 | * Returns true if this block can contain the given block as a child node |
||
63 | * |
||
64 | * @param AbstractBlock $block |
||
65 | * |
||
66 | * @return bool |
||
67 | */ |
||
68 | public function canContain(AbstractBlock $block) |
||
72 | |||
73 | /** |
||
74 | * Returns true if block type can accept lines of text |
||
75 | * |
||
76 | * @return bool |
||
77 | */ |
||
78 | 141 | public function acceptsLines() |
|
82 | |||
83 | /** |
||
84 | * Whether this is a code block |
||
85 | * |
||
86 | * @return bool |
||
87 | */ |
||
88 | public function isCode() |
||
92 | |||
93 | 75 | public function matchesNextLine(Cursor $cursor) |
|
97 | |||
98 | /** |
||
99 | * @param ContextInterface $context |
||
100 | * @param Cursor $cursor |
||
101 | */ |
||
102 | 123 | public function handleRemainingContents(ContextInterface $context, Cursor $cursor) |
|
106 | } |
||
107 |