Skip to content

Commit

Permalink
Add support for less indented comments in block scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
perlpunk committed Apr 19, 2018
1 parent 4220ed0 commit 6b062fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions lib/YAML/Loader.pm
Expand Up @@ -701,12 +701,19 @@ sub _parse_next_line {
}

if ($type == LEAF) {
while (@{$self->lines} and
$self->lines->[0] =~ m{^( *)(\#)} and
length($1) < $offset
) {
shift @{$self->lines};
$self->{line}++;
if (@{$self->lines} and $self->lines->[0] =~ m{^( *)(\#)}) {
if ( length($1) < $offset) {
shift @{$self->lines};
$self->{line}++;
# every comment after that is also thrown away regardless
# of identation
while (@{$self->lines} and
$self->lines->[0] =~ m{^( *)(\#)}
) {
shift @{$self->lines};
$self->{line}++;
}
}
}
$self->eos($self->{done} = not @{$self->lines});
}
Expand Down
2 changes: 1 addition & 1 deletion test/load-tests.t
Expand Up @@ -218,7 +218,7 @@ foo : bar
+++ perl
([2,3,4,5],
{foo => 'bar', boo => 'far'},
["# Not a comment; #Not a comment\n"],
["# Not a comment;\n"],
42)
=== several docs, some empty
+++ yaml
Expand Down

0 comments on commit 6b062fa

Please sign in to comment.