File tree 6 files changed +44
-18
lines changed
packages/guides-restructured-text/src/RestructuredText
directives/directive-configuration-block/expected 6 files changed +44
-18
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,12 @@ public function process(
62
62
BlockContext $ blockContext ,
63
63
Directive $ directive ,
64
64
): Node |null {
65
+ if ($ blockContext ->getDocumentIterator ()->isEmpty ()) {
66
+ $ this ->logger ->warning ('The code-block has no content. Did you properly indent the code? ' , $ blockContext ->getLoggerInformation ());
67
+
68
+ return null ;
69
+ }
70
+
65
71
$ node = new CodeNode (
66
72
$ blockContext ->getDocumentIterator ()->toArray (),
67
73
);
Original file line number Diff line number Diff line change 17
17
use OutOfBoundsException ;
18
18
19
19
use function chr ;
20
+ use function count ;
20
21
use function explode ;
21
22
use function max ;
22
23
use function mb_strpos ;
@@ -133,6 +134,11 @@ public function toArray(): array
133
134
return $ this ->lines ;
134
135
}
135
136
137
+ public function isEmpty (): bool
138
+ {
139
+ return count ($ this ->lines ) === 0 || (count ($ this ->lines ) === 1 && trim ($ this ->lines [0 ]) === '' );
140
+ }
141
+
136
142
/** @psalm-assert-if-false non-empty-string $line */
137
143
public static function isEmptyLine (string |null $ line ): bool
138
144
{
Original file line number Diff line number Diff line change
1
+ <!-- content start -->
2
+ < div class ="section " id ="title ">
3
+ < h1 > Title</ h1 >
4
+
5
+ < p > Some paragraph.</ p >
6
+ </ div >
7
+
8
+ <!-- content end -->
Original file line number Diff line number Diff line change
1
+ app.WARNING: The code-block has no content. Did you properly indent the code?
Original file line number Diff line number Diff line change
1
+ Title
2
+ =====
3
+
4
+ .. code-block :: xml
5
+
6
+ Some paragraph.
Original file line number Diff line number Diff line change 1
1
<!-- content start -->
2
2
< div class ="section " id ="directive-tests ">
3
- < h1 > Directive tests</ h1 >
3
+ < h1 > Directive tests</ h1 >
4
4
5
- < div class ="configuration-block ">
6
- < div role ="tablist " aria-label ="Configuration formats " class ="configuration-tabs configuration-tabs-length-2 ">
7
- < button role ="tab " type ="button " data-language ="yaml "
8
- aria-controls ="configuration-block-tabpanel-523eafc9524d67db5f21ecae2362d532 " aria-selected ="true "
9
- data-active ="true " >
10
- < span > Yaml</ span >
11
- </ button >
12
- < button role ="tab " type ="button " data-language ="custom "
13
- aria-controls ="configuration-block-tabpanel-a51ba27b3c76153f629592baf23834dc " aria-selected ="false "
14
- tabindex ="-1 ">
15
- < span > CUSTOM</ span >
16
- </ button >
5
+ < div class ="configuration-block ">
6
+ < div role ="tablist " aria-label ="Configuration formats " class ="configuration-tabs configuration-tabs-length-2 ">
7
+ < button role ="tab " type ="button " data-language ="yaml "
8
+ aria-controls ="configuration-block-tabpanel-523eafc9524d67db5f21ecae2362d532 " aria-selected ="true "
9
+ data-active ="true " >
10
+ < span > Yaml</ span >
11
+ </ button >
12
+ < button role ="tab " type ="button " data-language ="custom "
13
+ aria-controls ="configuration-block-tabpanel-a51ba27b3c76153f629592baf23834dc " aria-selected ="false "
14
+ tabindex ="-1 ">
15
+ < span > CUSTOM</ span >
16
+ </ button >
17
17
</ div >
18
18
19
19
< div role ="tabpanel " id ="configuration-block-tabpanel-523eafc9524d67db5f21ecae2362d532 " aria-label ="Yaml " class ="configuration-codeblock " data-language ="yaml " style ="">
20
- < pre > < code class ="language-yaml "> # app/config/services.yml</ code > </ pre >
21
- </ div >
20
+ < pre > < code class ="language-yaml "> # app/config/services.yml</ code > </ pre >
21
+ </ div >
22
22
< div role ="tabpanel " id ="configuration-block-tabpanel-a51ba27b3c76153f629592baf23834dc " aria-label ="CUSTOM " class ="configuration-codeblock " data-language ="custom " style ="display: none ">
23
- < pre > < code class ="language-php "> // config/routes.php</ code > </ pre >
24
- </ div >
23
+ < pre > < code class ="language-php "> // config/routes.php</ code > </ pre >
25
24
</ div >
26
-
27
25
</ div >
28
26
27
+ </ div >
29
28
30
29
<!-- content end -->
You can’t perform that action at this time.
0 commit comments