Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2439 from tbrowder/pod2text-fix
fix for missing defn features
  • Loading branch information
tbrowder committed Oct 28, 2018
2 parents 5a932f3 + f1c03c6 commit 3416f23
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
29 changes: 15 additions & 14 deletions lib/Pod/To/Text.pm6
Expand Up @@ -12,18 +12,21 @@ if %*ENV<POD_TO_TEXT_ANSI> {

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 }
}
}

Expand All @@ -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) }
Expand Down
11 changes: 7 additions & 4 deletions src/core/Pod.pm6
Expand Up @@ -8,7 +8,7 @@ my class Pod::Block {
my $leading = ' ' x $level;
my %confs;
my @chunks;
for <config name level caption type> {
for <config name level caption type term> {
my $thing = $pod.?"$_"();
if $thing {
%confs{$_} = nqp::istype($thing,Iterable)
Expand Down Expand Up @@ -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 {
[]
}
}
Expand Down

0 comments on commit 3416f23

Please sign in to comment.