@@ -295,6 +295,42 @@ public function parse($value, $flags = 0)
295
295
return $ value ;
296
296
}
297
297
298
+ // try to parse the value as a multi-line string as a last resort
299
+ if (0 === $ this ->currentLineNb ) {
300
+ $ parseError = false ;
301
+ $ previousLineWasNewline = false ;
302
+ $ value = '' ;
303
+
304
+ foreach ($ this ->lines as $ line ) {
305
+ try {
306
+ $ parsedLine = Inline::parse ($ line , $ flags , $ this ->refs );
307
+
308
+ if (!is_string ($ value )) {
309
+ $ parseError = true ;
310
+ break ;
311
+ }
312
+
313
+ if ('' === trim ($ parsedLine )) {
314
+ $ value .= "\n" ;
315
+ $ previousLineWasNewline = true ;
316
+ } elseif ($ previousLineWasNewline ) {
317
+ $ value .= trim ($ parsedLine );
318
+ $ previousLineWasNewline = false ;
319
+ } else {
320
+ $ value .= ' ' .trim ($ parsedLine );
321
+ $ previousLineWasNewline = false ;
322
+ }
323
+ } catch (ParseException $ e ) {
324
+ $ parseError = true ;
325
+ break ;
326
+ }
327
+ }
328
+
329
+ if (!$ parseError ) {
330
+ return trim ($ value );
331
+ }
332
+ }
333
+
298
334
switch (preg_last_error ()) {
299
335
case PREG_INTERNAL_ERROR :
300
336
$ error = 'Internal PCRE error. ' ;
@@ -462,7 +498,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
462
498
463
499
$ previousLineIndentation = $ indent ;
464
500
465
- if ($ isItUnindentedCollection && !$ this ->isStringUnIndentedCollectionItem () && $ newIndent === $ indent ) {
501
+ if ($ isItUnindentedCollection && !$ this ->isCurrentLineEmpty () && ! $ this -> isStringUnIndentedCollectionItem () && $ newIndent === $ indent ) {
466
502
$ this ->moveToPreviousLine ();
467
503
break ;
468
504
}
0 commit comments