Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb4f5b18

Browse files
committed
Adding admonition directive & simplifying some admonition markup
1 parente1f1632 commitb4f5b18

File tree

16 files changed

+63
-17
lines changed

16 files changed

+63
-17
lines changed

‎_build/src/Directive/AbstractAdmonitionDirective.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ final public function processSub(Parser $parser, ?Node $document, string $variab
2727
[
2828
'name' =>$this->name,
2929
'text' =>$this->text,
30+
'class' =>null,
3031
]
3132
);
3233

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespaceSymfonyDocs\Directive;
4+
5+
useDoctrine\RST\Directives\SubDirective;
6+
useDoctrine\RST\Nodes\Node;
7+
useDoctrine\RST\Parser;
8+
9+
class AdmonitionDirectiveextends SubDirective
10+
{
11+
publicfunctionprocessSub(Parser$parser, ?Node$document,string$variable,string$data,array$options): ?Node
12+
{
13+
$wrapperDiv =$parser->renderTemplate(
14+
'directives/admonition.html.twig',
15+
[
16+
// a bit strange, but on the old markup we literally
17+
// had a class of 'admonition-"
18+
'name' =>'',
19+
'text' =>$data,
20+
'class' =>isset($options['class']) ?$options['class'] :null,
21+
]
22+
);
23+
24+
return$parser->getNodeFactory()->createWrapperNode($document,$wrapperDiv,'</div></div>');
25+
}
26+
27+
publicfunctiongetName():string
28+
{
29+
return'admonition';
30+
}
31+
}

‎_build/src/KernelFactory.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static function (string $path) use ($parseOnlyPath) : bool {
4848
privatestaticfunctiongetDirectives():array
4949
{
5050
return [
51+
newSymfonyDirectives\AdmonitionDirective(),
5152
newSymfonyDirectives\CautionDirective(),
5253
newSymfonyDirectives\ClassDirective(),
5354
newSymfonyDirectives\CodeBlockDirective(),
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<divclass="admonition-{{name }} admonition-wrapper">
2-
<divclass="{{name }}"></div>
1+
<divclass="admonition-wrapper{{class? (''~class):'' }}">
32
<divclass="admonition admonition-{{name }}">
43
<pclass="admonition-title">{{text }}</p>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<divclass="admonition-wrapper"><divclass="sidebar"></div><divclass="admonition admonition-sidebar"><pclass="sidebar-title">{{title|raw }}</p>
1+
<divclass="admonition-wrapper"><divclass="admonition admonition-sidebar"><pclass="sidebar-title">{{title|raw }}</p>

‎_build/tests/IntegrationTest.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ public function parserUnitBlockProvider()
144144
'blockName' =>'directives/note',
145145
];
146146

147+
yield'admonition' => [
148+
'blockName' =>'directives/admonition',
149+
];
150+
147151
yield'note-code-block-nested' => [
148152
'blockName' =>'directives/note-code-block-nested',
149153
];
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<metacharset="utf-8"/>
5+
</head>
6+
<body>
7+
<divclass="admonition-wrapper screencast_class">
8+
<divclass="admonition admonition-">
9+
<pclass="admonition-title">Screencast</p>
10+
<p>Do you prefer video tutorials? Check out the the screencasts.</p>
11+
</div>
12+
</div>
13+
</body>
14+
</html>

‎_build/tests/fixtures/expected/blocks/directives/best-practice.html‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
<metacharset="utf-8"/>
55
</head>
66
<body>
7-
<divclass="admonition-best-practice admonition-wrapper">
8-
<divclass="best-practice"></div>
7+
<divclass="admonition-wrapper">
98
<divclass="admonition admonition-best-practice">
109
<pclass="admonition-title">Best Practice</p>
1110
<p>Use the bcrypt encoder for hashing your users' passwords.</p>

‎_build/tests/fixtures/expected/blocks/directives/caution.html‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
<metacharset="utf-8"/>
55
</head>
66
<body>
7-
<divclass="admonition-caution admonition-wrapper">
8-
<divclass="caution"></div>
7+
<divclass="admonition-wrapper">
98
<divclass="admonition admonition-caution">
109
<pclass="admonition-title">Caution</p>
1110
<p>Using too many sidebars or caution directives can be distracting!</p>

‎_build/tests/fixtures/expected/blocks/directives/note-code-block-nested.html‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
<metacharset="utf-8"/>
55
</head>
66
<body>
7-
<divclass="admonition-note admonition-wrapper">
8-
<divclass="note"></div>
7+
<divclass="admonition-wrapper">
98
<divclass="admonition admonition-note">
109
<pclass="admonition-title">Note</p>
1110
<p>test</p>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp