Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge twines properly in paragraph blocks
  • Loading branch information
Tadeusz Sośnierz committed Aug 15, 2011
1 parent a98e265 commit 02e5a62
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/Perl6/Actions.pm
Expand Up @@ -323,16 +323,29 @@ class Perl6::Actions is HLL::Actions {
}

method pod_textcontent:sym<regular>($/) {
my @t;
for $<pod_string> {
nqp::splice(@t, $_.ast, +@t, 0)
}
my @t := self.merge_twines($<pod_string>);
my $twine := Perl6::Pod::serialize_array(@t)<compile_time_value>;
make Perl6::Pod::serialize_object(
'Pod::Block::Para', :content($twine)
)<compile_time_value>
}

method merge_twines(@twines) {
my @ret := [];
@ret.push($*ST.add_constant('Str', 'str', '')<compile_time_value>);
for @twines {
my @cur := $_.ast;
@ret.push(
$*ST.add_constant(
'Str', 'str',
nqp::unbox_s(@ret.pop) ~ nqp::unbox_s(@cur.shift)
)<compile_time_value>,
);
nqp::splice(@ret, @cur, +@ret, 0);
}
return @ret;
}

method pod_textcontent:sym<code>($/) {
my $s := $<spaces>.Str;
my $t := subst($<text>.Str, /\n$s/, "\n", :global);
Expand Down

0 comments on commit 02e5a62

Please sign in to comment.