File tree Expand file tree Collapse file tree 3 files changed +40
-4
lines changed
Expand file tree Collapse file tree 3 files changed +40
-4
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ ## 0.5.2 - 2021-09-26
6+
7+ ### Fixed
8+ - Indented code works correctly now.
9+
510## 0.5.1 - 2021-09-06
611
712### Changed
Original file line number Diff line number Diff line change 33namespace Torchlight \Commonmark ;
44
55use Illuminate \Support \Str ;
6- use League \CommonMark \Block \Element \IndentedCode ;
76use League \CommonMark \Event \DocumentParsedEvent ;
87use League \CommonMark \Util \Xml ;
98use Torchlight \Block ;
@@ -170,8 +169,12 @@ protected function getContent($node)
170169 */
171170 protected function getInfo ($ node )
172171 {
173- if (!$ this ->isCodeNode ($ node ) || $ node instanceof IndentedCode) {
174- return null ;
172+ if (!$ this ->isCodeNode ($ node )) {
173+ return [];
174+ }
175+
176+ if (!is_callable ([$ node , 'getInfoWords ' ])) {
177+ return [];
175178 }
176179
177180 $ infoWords = $ node ->getInfoWords ();
@@ -185,7 +188,13 @@ protected function getInfo($node)
185188 */
186189 protected function getLanguage ($ node )
187190 {
188- $ language = $ this ->getInfo ($ node )[0 ];
191+ $ info = $ this ->getInfo ($ node );
192+
193+ if (empty ($ info )) {
194+ return null ;
195+ }
196+
197+ $ language = $ info [0 ];
189198
190199 return $ language ? Xml::escape ($ language , true ) : null ;
191200 }
Original file line number Diff line number Diff line change @@ -118,6 +118,28 @@ public function can_set_theme()
118118 });
119119 }
120120
121+ /** @test */
122+ public function indented_code_doesnt_fail ()
123+ {
124+ $ markdown = <<<'EOT'
125+ before
126+
127+ <div>test</div>
128+
129+ after
130+ EOT;
131+
132+ Http::fake ();
133+
134+ $ this ->render ($ markdown );
135+
136+ Http::assertSent (function ($ request ) {
137+ return $ request ['blocks ' ][0 ]['language ' ] === null
138+ && $ request ['blocks ' ][0 ]['code ' ] === '<div>test</div> ' ;
139+ });
140+ }
141+
142+
121143 /** @test */
122144 public function can_load_file ()
123145 {
You can’t perform that action at this time.
0 commit comments