我正在尝试将嵌入式Pod作为ANSI文本输出到终端。在Perl 5中,我可以使用Pod::Text::Termcap:
use strict;
use warnings;
use Pod::Text::Termcap;
my $str = do {local $/; <DATA>};
my $parser = Pod::Text::Termcap->new();
$parser->parse_string_document( $str, \*STDERR );
__DATA__
=head1 SYNOPSIS
my_test_command I<filename> [OPTIONS]
=head1 ARGUMENTS
=over 4
=item I<filename>
File name to test
=back
=head1 OPTIONS
=over 4
=item B<--help>
Prints help
=back
=head1 DESCRIPTION
A sample test command with embedded Pod
Run Code Online (Sandbox Code Playgroud)
输出:
我试图在Perl 6中实现相同的目标:
use v6;
%*ENV<POD_TO_TEXT_ANSI> = 1;
my @lines;
for $=pod -> $pod-block {
for $pod-block.contents -> $pod-item …Run Code Online (Sandbox Code Playgroud)