Skip to content

Commit

Permalink
Improve emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
perlpunk committed Jan 26, 2020
1 parent 34bc7da commit def51cf
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 174 deletions.
2 changes: 1 addition & 1 deletion bin/yamlpp5-parse-emit
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ for my $event (@events) {
my $type = $event->{name};
my $str = YAML::PP::Common::event_to_test_suite($event);
print "$str\n" if $verbose;
if ($type eq 'sequence_start_event' or $type eq 'mapping_end_event') {
if ($type eq 'sequence_start_event' or $type eq 'mapping_start_event') {
delete $event->{style};
}
$emitter->$type($event);
Expand Down
7 changes: 7 additions & 0 deletions lib/YAML/PP/Dumper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ sub emit_node {
}
if ($type eq 'mapping') {
my $style = YAML_BLOCK_MAPPING_STYLE;
# TODO
if ($node->{items} and @{ $node->{items} } == 0) {
# $style = YAML_FLOW_MAPPING_STYLE;
}
$self->emitter->mapping_start_event({
anchor => $node->{anchor},
style => $style,
Expand All @@ -151,6 +155,9 @@ sub emit_node {
}
if ($type eq 'sequence') {
my $style = YAML_BLOCK_SEQUENCE_STYLE;
if (@{ $node->{items} } == 0) {
# $style = YAML_FLOW_SEQUENCE_STYLE;
}
$self->emitter->sequence_start_event({
anchor => $node->{anchor},
style => $style,
Expand Down
Loading

0 comments on commit def51cf

Please sign in to comment.