diff --git a/lib/Pod/To/Text.pm6 b/lib/Pod/To/Text.pm6 index 0fdaa9cd27c..7c3ba894dc7 100644 --- a/lib/Pod/To/Text.pm6 +++ b/lib/Pod/To/Text.pm6 @@ -12,18 +12,21 @@ if %*ENV { sub pod2text($pod) is export { given $pod { - when Pod::Heading { heading2text($pod) } - when Pod::Block::Code { code2text($pod) } - when Pod::Block::Named { named2text($pod) } - when Pod::Block::Para { twrap( $pod.contents.map({pod2text($_)}).join("") ) } - when Pod::Block::Table { table2text($pod) } - when Pod::Block::Declarator { declarator2text($pod) } - when Pod::Item { item2text($pod).indent(2) } - when Pod::FormattingCode { formatting2text($pod) } - when Positional { .flatĀ».&pod2text.grep(?*).join: "\n\n" } - when Pod::Block::Comment { '' } - when Pod::Config { '' } - default { $pod.Str } + when Pod::Heading { heading2text($pod) } + when Pod::Block::Code { code2text($pod) } + when Pod::Block::Named { named2text($pod) } + when Pod::Block::Para { twrap( $pod.contents.map({pod2text($_)}).join("") ) } + when Pod::Block::Table { table2text($pod) } + when Pod::Block::Declarator { declarator2text($pod) } + when Pod::Item { item2text($pod).indent(2) } + when Pod::Defn { pod2text($pod.contents[0]) ~ "\n" + ~ pod2text($pod.contents[1..*-1]) } + + when Pod::FormattingCode { formatting2text($pod) } + when Positional { .flatĀ».&pod2text.grep(?*).join: "\n\n" } + when Pod::Block::Comment { '' } + when Pod::Config { '' } + default { $pod.Str } } } @@ -47,8 +50,6 @@ sub named2text($pod) { given $pod.name { when 'pod' { pod2text($pod.contents) } when 'para' { para2text($pod.contents[0]) } - when 'defn' { pod2text($pod.contents[0]) ~ "\n" - ~ pod2text($pod.contents[1..*-1]) } when 'config' { } when 'nested' { } default { $pod.name ~ "\n" ~ pod2text($pod.contents) } diff --git a/src/core/Pod.pm6 b/src/core/Pod.pm6 index 6b190ebce55..be9dea7c713 100644 --- a/src/core/Pod.pm6 +++ b/src/core/Pod.pm6 @@ -8,7 +8,7 @@ my class Pod::Block { my $leading = ' ' x $level; my %confs; my @chunks; - for { + for { my $thing = $pod.?"$_"(); if $thing { %confs{$_} = nqp::istype($thing,Iterable) @@ -69,11 +69,14 @@ my class Pod::Block::Declarator is Pod::Block { method contents { if @!leading && @!trailing { [ $.leading ~ "\n" ~ $.trailing ] - } elsif @!leading { + } + elsif @!leading { [ $.leading ] - } elsif @!trailing { + } + elsif @!trailing { [ $.trailing ] - } else { + } + else { [] } }