1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the league/commonmark package. |
5
|
|
|
* |
6
|
|
|
* (c) Davey Shafik <[email protected]> |
7
|
|
|
* (c) Colin O'Dell <[email protected]> |
8
|
|
|
* (c) Dan Hunsaker <[email protected]> |
9
|
|
|
* |
10
|
|
|
* Original code based on the CommonMark JS reference parser (http://bitly.com/commonmarkjs) |
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 Danhunsaker\Markua\Block\Element; |
18
|
|
|
|
19
|
|
|
use League\CommonMark\Block\Element\AbstractBlock; |
20
|
|
|
use League\CommonMark\Block\Element\Paragraph; |
21
|
|
|
use League\CommonMark\ContextInterface; |
22
|
|
|
use League\CommonMark\Cursor; |
23
|
|
|
|
24
|
|
|
class Aside extends AbstractBlock |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
30 |
|
public function canContain(AbstractBlock $block) |
30
|
|
|
{ |
31
|
30 |
|
return true; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
30 |
|
public function acceptsLines() |
38
|
|
|
{ |
39
|
30 |
|
return false; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
30 |
|
public function isCode() |
46
|
|
|
{ |
47
|
30 |
|
return false; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
*/ |
53
|
6 |
|
public function matchesNextLine(Cursor $cursor) |
54
|
|
|
{ |
55
|
6 |
|
if ($cursor->getIndent() <= 3 && $cursor->getNextNonSpaceCharacter() == 'A') { |
56
|
5 |
|
$cursor->advanceToNextNonSpaceOrNewline(); |
57
|
5 |
|
if ($cursor->peek() === '>') { |
58
|
4 |
|
$cursor->advanceBy(2); |
59
|
4 |
|
if ($cursor->getCharacter() === ' ') { |
60
|
4 |
|
$cursor->advance(); |
61
|
4 |
|
} |
62
|
4 |
|
return true; |
63
|
|
|
} |
64
|
1 |
|
} |
65
|
|
|
|
66
|
2 |
|
return false; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritdoc} |
71
|
|
|
*/ |
72
|
|
|
public function handleRemainingContents(ContextInterface $context, Cursor $cursor) |
73
|
|
|
{ |
74
|
|
|
if ($cursor->isBlank()) { |
75
|
|
|
return; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
$context->addBlock(new Paragraph()); |
79
|
|
|
$cursor->advanceToNextNonSpaceOrNewline(); |
80
|
|
|
$context->getTip()->addLine($cursor->getRemainder()); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* {@inheritdoc} |
85
|
|
|
*/ |
86
|
30 |
|
public function setLastLineBlank($blank) |
87
|
|
|
{ |
88
|
30 |
|
$this->lastLineBlank = false; |
89
|
30 |
|
} |
90
|
|
|
} |
91
|
|
|
|