Skip to content

Commit

Permalink
fix(yml): fix comment in milti line value
Browse files Browse the repository at this point in the history
  • Loading branch information
soufianZantar committed Jul 30, 2019
1 parent 051d045 commit 1a0bae0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ private function doParse($value, $flags)
$value = '';

foreach ($this->lines as $line) {
if ('' !== ltrim($line) && '#' === ltrim($line)[0]) {
continue;
}
// If the indentation is not consistent at offset 0, it is to be considered as a ParseError
if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) {
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
Expand Down
12 changes: 12 additions & 0 deletions Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,18 @@ public function indentedMappingData()

return $tests;
}

public function testMultiLineComment()
{
$yaml = <<<YAML
parameters:
abc
# Comment
YAML;

$this->assertSame(['parameters' => 'abc'], $this->parser->parse($yaml));
}
}

class B
Expand Down

0 comments on commit 1a0bae0

Please sign in to comment.