File tree 3 files changed +40
-4
lines changed
3 files changed +40
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ ## 0.5.2 - 2021-09-26
6
+
7
+ ### Fixed
8
+ - Indented code works correctly now.
9
+
5
10
## 0.5.1 - 2021-09-06
6
11
7
12
### Changed
Original file line number Diff line number Diff line change 3
3
namespace Torchlight \Commonmark ;
4
4
5
5
use Illuminate \Support \Str ;
6
- use League \CommonMark \Block \Element \IndentedCode ;
7
6
use League \CommonMark \Event \DocumentParsedEvent ;
8
7
use League \CommonMark \Util \Xml ;
9
8
use Torchlight \Block ;
@@ -170,8 +169,12 @@ protected function getContent($node)
170
169
*/
171
170
protected function getInfo ($ node )
172
171
{
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 [];
175
178
}
176
179
177
180
$ infoWords = $ node ->getInfoWords ();
@@ -185,7 +188,13 @@ protected function getInfo($node)
185
188
*/
186
189
protected function getLanguage ($ node )
187
190
{
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 ];
189
198
190
199
return $ language ? Xml::escape ($ language , true ) : null ;
191
200
}
Original file line number Diff line number Diff line change @@ -118,6 +118,28 @@ public function can_set_theme()
118
118
});
119
119
}
120
120
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
+
121
143
/** @test */
122
144
public function can_load_file ()
123
145
{
You can’t perform that action at this time.
0 commit comments