Skip to content

Commit 1a0bae0

Browse files
committed
fix(yml): fix comment in milti line value
1 parent 051d045 commit 1a0bae0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Parser.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,9 @@ private function doParse($value, $flags)
436436
$value = '';
437437

438438
foreach ($this->lines as $line) {
439+
if ('' !== ltrim($line) && '#' === ltrim($line)[0]) {
440+
continue;
441+
}
439442
// If the indentation is not consistent at offset 0, it is to be considered as a ParseError
440443
if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) {
441444
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);

Tests/ParserTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,18 @@ public function indentedMappingData()
22922292

22932293
return $tests;
22942294
}
2295+
2296+
public function testMultiLineComment()
2297+
{
2298+
$yaml = <<<YAML
2299+
parameters:
2300+
abc
2301+
2302+
# Comment
2303+
YAML;
2304+
2305+
$this->assertSame(['parameters' => 'abc'], $this->parser->parse($yaml));
2306+
}
22952307
}
22962308

22972309
class B

0 commit comments

Comments
 (0)