1 | <?php |
||
20 | class Paragraph extends AbstractBlock implements InlineContainerInterface |
||
21 | { |
||
22 | /** |
||
23 | * Returns true if this block can contain the given block as a child node |
||
24 | * |
||
25 | * @param AbstractBlock $block |
||
26 | * |
||
27 | * @return bool |
||
28 | */ |
||
29 | 69 | public function canContain(AbstractBlock $block) |
|
33 | |||
34 | /** |
||
35 | * Returns true if block type can accept lines of text |
||
36 | * |
||
37 | * @return bool |
||
38 | */ |
||
39 | 1608 | public function acceptsLines() |
|
43 | |||
44 | /** |
||
45 | * Whether this is a code block |
||
46 | * |
||
47 | * @return bool |
||
48 | */ |
||
49 | 357 | public function isCode() |
|
53 | |||
54 | 687 | public function matchesNextLine(Cursor $cursor) |
|
64 | |||
65 | 1572 | public function finalize(ContextInterface $context, $endLineNumber) |
|
66 | { |
||
67 | 1572 | parent::finalize($context, $endLineNumber); |
|
68 | |||
69 | 1572 | $this->finalStringContents = preg_replace('/^ */m', '', implode("\n", $this->getStrings())); |
|
70 | |||
71 | // Short-circuit |
||
72 | 1572 | if ($this->finalStringContents === '' || $this->finalStringContents[0] !== '[') { |
|
73 | 1260 | return; |
|
74 | } |
||
75 | |||
76 | 390 | $cursor = new Cursor($this->finalStringContents); |
|
77 | |||
78 | 390 | $referenceFound = $this->parseReferences($context, $cursor); |
|
79 | |||
80 | 390 | $this->finalStringContents = $cursor->getRemainder(); |
|
81 | |||
82 | 390 | if ($referenceFound && $cursor->isAtEnd()) { |
|
83 | 216 | $this->detach(); |
|
84 | 144 | } |
|
85 | 390 | } |
|
86 | |||
87 | /** |
||
88 | * @param ContextInterface $context |
||
89 | * @param Cursor $cursor |
||
90 | * |
||
91 | * @return bool |
||
92 | */ |
||
93 | 390 | protected function parseReferences(ContextInterface $context, Cursor $cursor) |
|
103 | |||
104 | /** |
||
105 | * @param ContextInterface $context |
||
106 | * @param Cursor $cursor |
||
107 | */ |
||
108 | 252 | public function handleRemainingContents(ContextInterface $context, Cursor $cursor) |
|
113 | } |
||
114 |