Skip to content

Commit a97bc04

Browse files
committed
1 parent 7a35400 commit a97bc04

File tree

13 files changed

+105
-75
lines changed

13 files changed

+105
-75
lines changed

packages/guides-markdown/src/Markdown/Parsers/BlockQuoteParser.php

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
use Psr\Log\LoggerInterface;
2828
use RuntimeException;
2929

30+
use function array_shift;
31+
use function count;
3032
use function sprintf;
33+
use function trim;
3134

3235
/** @extends AbstractBlockParser<Node> */
3336
final class BlockQuoteParser extends AbstractBlockParser
@@ -59,8 +62,8 @@ public function parse(MarkupLanguageParser $parser, NodeWalker $walker, CommonMa
5962

6063
// leaving the heading node
6164
if ($commonMarkNode instanceof BlockQuote) {
62-
if (count($content) > 0 and $content[0] instanceof ParagraphNode and $content[0]->getValue()[0]) {
63-
$paragraphContent = $content[0]->getValue();
65+
if (count($content) > 0 and $content[0] instanceof ParagraphNode and ($content[0]->getValue()[0]) instanceof InlineCompoundNode) {
66+
$paragraphContent = $content[0]->getValue()[0]->getValue();
6467
if (count($paragraphContent) > 0 and $paragraphContent[0] instanceof PlainTextInlineNode) {
6568
$text = trim($paragraphContent[0]->getValue());
6669
$newParagraphContent = $paragraphContent;
@@ -71,12 +74,46 @@ public function parse(MarkupLanguageParser $parser, NodeWalker $walker, CommonMa
7174
'note',
7275
new InlineCompoundNode([new PlainTextInlineNode('Note')]),
7376
'Note',
74-
$newParagraphContent
77+
$newParagraphContent,
78+
);
79+
80+
case '[!TIP]':
81+
return new AdmonitionNode(
82+
'tip',
83+
new InlineCompoundNode([new PlainTextInlineNode('Tip')]),
84+
'Tip',
85+
$newParagraphContent,
86+
);
87+
88+
case '[!IMPORTANT]':
89+
return new AdmonitionNode(
90+
'important',
91+
new InlineCompoundNode([new PlainTextInlineNode('Important')]),
92+
'Important',
93+
$newParagraphContent,
94+
);
95+
96+
case '[!WARNING]':
97+
return new AdmonitionNode(
98+
'warning',
99+
new InlineCompoundNode([new PlainTextInlineNode('Warning')]),
100+
'Warning',
101+
$newParagraphContent,
102+
);
103+
104+
case '[!CAUTION]':
105+
return new AdmonitionNode(
106+
'caution',
107+
new InlineCompoundNode([new PlainTextInlineNode('Caution')]),
108+
'Caution',
109+
$newParagraphContent,
75110
);
76111
}
77112
}
78-
$content[0] = new ParagraphNode( [new InlineCompoundNode($paragraphContent)]);
113+
114+
$content[0] = new ParagraphNode([new InlineCompoundNode($paragraphContent)]);
79115
}
116+
80117
return new QuoteNode($content);
81118
}
82119

packages/guides-restructured-text/src/RestructuredText/Directives/AdmonitionDirective.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use phpDocumentor\Guides\Nodes\Node;
1919
use phpDocumentor\Guides\RestructuredText\Parser\BlockContext;
2020
use phpDocumentor\Guides\RestructuredText\Parser\Directive;
21+
2122
use function preg_replace;
2223
use function strtolower;
2324
use function trim;

packages/guides-restructured-text/src/RestructuredText/NodeRenderers/Html/AdmonitionNodeRenderer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use phpDocumentor\Guides\Nodes\Node;
2020
use phpDocumentor\Guides\RenderContext;
2121
use phpDocumentor\Guides\TemplateRenderer;
22+
2223
use function implode;
2324
use function is_a;
2425

packages/guides-theme-bootstrap/resources/template/body/admonition.html.twig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
1+
{% if name == 'caution' %}
2+
{% include "body/admonitions/caution.html.twig" %}
3+
{% endif %}
24
{% if name == 'important' %}
35
{% include "body/admonitions/important.html.twig" %}
46
{% endif %}
57
{% if name == 'note' %}
68
{% include "body/admonitions/note.html.twig" %}
79
{% endif %}
8-
{% if name == 'warning' or name == 'caution' %}
10+
{% if name == 'warning' %}
911
{% include "body/admonitions/warning.html.twig" %}
1012
{% endif %}
1113
{% if name == 'tip' or name == 'hint' %}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="alert alert-danger {{ class ? (' '~class) }}{% if node.classes %} {{ node.classesString }}{% endif %}" role="alert">
2+
<h4 class="alert-heading">Caution</h4>
3+
{{ renderNode(node) }}
4+
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="alert alert-danger {{ class ? (' '~class) }}{% if node.classes %} {{ node.classesString }}{% endif %}" role="alert">
2-
<h4 class="alert-heading">Tip</h4>
1+
<div class="alert alert-warning {{ class ? (' '~class) }}{% if node.classes %} {{ node.classesString }}{% endif %}" role="alert">
2+
<h4 class="alert-heading">Imortant</h4>
33
{{ renderNode(node) }}
44
</div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<div class="alert alert-danger {{ class ? (' '~class) }}{% if node.classes %} {{ node.classesString }}{% endif %}" role="alert">
2-
<h4 class="alert-heading">Tip</h4>
2+
<h4 class="alert-heading">Warning</h4>
33
{{ renderNode(node) }}
44
</div>

tests/Integration/tests/bootstrap/bootstrap-admonition/expected/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<!-- content start -->
22
<div class="section" id="document-title">
33
<h1>Document Title</h1>
4-
5-
<div class="alert alert-info " role="alert">
4+
<div class="alert alert-info " role="alert">
65
<h4 class="alert-heading">Tip</h4>
76

87
<p>Lorem Ipsum Dolor.</p>
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<!-- content start -->
2-
<div class="section" id="directive-tests">
3-
<h1>Directive tests</h1>
4-
<p>Lorem Ipsum Dolor</p>
5-
<p>Dolor sit!</p>
6-
</div>
2+
<div class="section" id="directive-tests">
3+
<h1>Directive tests</h1>
4+
5+
6+
<p>Lorem Ipsum Dolor</p>
7+
8+
<p>Dolor sit!</p>
9+
10+
</div>
711
<!-- content end -->
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<!-- content start -->
2-
<div class="section" id="directive-tests">
3-
<h1>Directive tests</h1>
4-
<div>
5-
<p>Lorem Ipsum Dolor</p>
6-
<h2>Some Rubric</h2>
7-
<p>Dolor sit!</p>
8-
</div>
2+
<div class="section" id="directive-tests">
3+
<h1>Directive tests</h1>
4+
<div>
5+
6+
<p>Lorem Ipsum Dolor</p>
7+
<h2>Some Rubric</h2>
8+
<p>Dolor sit!</p>
99
</div>
10+
</div>
1011
<!-- content end -->

0 commit comments

Comments
 (0)