File tree Expand file tree Collapse file tree 6 files changed +44
-18
lines changed
packages/guides-restructured-text/src/RestructuredText
directives/directive-configuration-block/expected Expand file tree Collapse file tree 6 files changed +44
-18
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,12 @@ public function process(
6262 BlockContext $ blockContext ,
6363 Directive $ directive ,
6464 ): 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+
6571 $ node = new CodeNode (
6672 $ blockContext ->getDocumentIterator ()->toArray (),
6773 );
Original file line number Diff line number Diff line change 1717use OutOfBoundsException ;
1818
1919use function chr ;
20+ use function count ;
2021use function explode ;
2122use function max ;
2223use function mb_strpos ;
@@ -133,6 +134,11 @@ public function toArray(): array
133134 return $ this ->lines ;
134135 }
135136
137+ public function isEmpty (): bool
138+ {
139+ return count ($ this ->lines ) === 0 || (count ($ this ->lines ) === 1 && trim ($ this ->lines [0 ]) === '' );
140+ }
141+
136142 /** @psalm-assert-if-false non-empty-string $line */
137143 public static function isEmptyLine (string |null $ line ): bool
138144 {
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 11<!-- content start -->
22 < div class ="section " id ="directive-tests ">
3- < h1 > Directive tests</ h1 >
3+ < h1 > Directive tests</ h1 >
44
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 >
1717 </ div >
1818
1919 < 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 >
2222 < 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 >
2524 </ div >
26-
2725 </ div >
2826
27+ </ div >
2928
3029<!-- content end -->
You can’t perform that action at this time.
0 commit comments