Permalink
Browse files

[Pod::To::Text] Generate proper output for Tables and Comments, fix o…

…utput for Named blocks
  • Loading branch information...
1 parent 62bd6a7 commit 77c62ce554277f4690b7b341363c51e330859771 @tadzik tadzik committed Aug 9, 2011
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/Pod/To/Text.pm
View
@@ -7,9 +7,11 @@ sub pod2text($pod) is export {
when Pod::Block::Code { code2text($pod) }
when Pod::Block::Named { named2text($pod) }
when Pod::Block::Para { para2text($pod) }
+ when Pod::Block::Table { table2text($pod) }
when Pod::Block::Declarator { declarator2text($pod) }
when Pod::Item { item2text($pod) }
when Positional { $pod.map({pod2text($_)}).join("\n\n")}
+ when Pod::Block::Comment { }
default { $pod.Str }
}
}
@@ -31,13 +33,20 @@ sub item2text($pod) {
}
sub named2text($pod) {
- $pod.name eq 'pod' ?? pod2text($pod.content) !! para2text($pod)
+ $pod.name eq 'pod' ?? pod2text($pod.content)
+ !! $pod.name ~ "\n" ~ pod2text($pod.content)
}
sub para2text($pod) {
$pod.content.join("\n")
}
+sub table2text($pod) {
+ ($pod.caption // '')
+ ~ ($pod.headers ?? $pod.headers.join("\t") ~ "\n" !! '')
+ ~ ($pod.content.map({ $_.join("\t") }).join("\n"))
+}
+
sub declarator2text($pod) {
next unless $pod.WHEREFORE.WHY;
do given $pod.WHEREFORE {

0 comments on commit 77c62ce

Please sign in to comment.