| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Pod::Simple::Text::Termcap; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22219
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
27
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1472
|
use Pod::Simple::Text (); |
|
|
1
|
|
|
|
|
46143
|
|
|
|
1
|
|
|
|
|
23
|
|
|
7
|
1
|
|
|
1
|
|
1191
|
use Term::Cap; |
|
|
1
|
|
|
|
|
4359
|
|
|
|
1
|
|
|
|
|
41
|
|
|
8
|
1
|
|
|
1
|
|
8
|
use vars qw/@ISA $VERSION %BOLD %ITALIC/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
371
|
|
|
9
|
|
|
|
|
|
|
@ISA = qw(Pod::Simple::Text); |
|
10
|
|
|
|
|
|
|
$VERSION = '0.01'; |
|
11
|
|
|
|
|
|
|
@BOLD{qw/B head1 head2 head3 head4/} = (); |
|
12
|
|
|
|
|
|
|
@ITALIC{qw/F I/} = (); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _handle_element_start { |
|
15
|
0
|
|
|
0
|
|
|
my ( $parser, $element_name, $attr_hash_r ) = @_; |
|
16
|
0
|
|
|
|
|
|
my $self = shift; |
|
17
|
0
|
0
|
|
|
|
|
my @ret = wantarray |
|
18
|
|
|
|
|
|
|
? $self->SUPER::_handle_element_start(@_) |
|
19
|
|
|
|
|
|
|
: scalar( $self->SUPER::_handle_element_start(@_) ); |
|
20
|
0
|
0
|
|
|
|
|
$self->{'Thispara'} .= $self->{_BOLD} if exists $BOLD{$element_name}; |
|
21
|
0
|
0
|
|
|
|
|
$self->{'Thispara'} .= $self->{_UNDL} if exists $ITALIC{$element_name}; |
|
22
|
0
|
|
|
|
|
|
return @ret; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _handle_element_end { |
|
26
|
0
|
|
|
0
|
|
|
my ( $parser, $element_name ) = @_; |
|
27
|
0
|
0
|
0
|
|
|
|
$_[0]->{'Thispara'} .= $_[0]->{_NORM} |
|
28
|
|
|
|
|
|
|
if exists $BOLD{$element_name} || exists $ITALIC{$element_name}; |
|
29
|
0
|
|
|
|
|
|
goto \&{ $_[0]->can('SUPER::_handle_element_end') }; |
|
|
0
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
|
33
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
34
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
|
35
|
0
|
|
|
|
|
|
bless $self, $class; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Fall back on the ANSI escape sequences if Term::Cap doesn't work. |
|
38
|
0
|
|
|
|
|
|
my $term; |
|
39
|
0
|
|
|
|
|
|
eval { $term = Tgetent Term::Cap { TERM => undef, OSPEED => 9600 } }; |
|
|
0
|
|
|
|
|
|
|
|
40
|
0
|
|
0
|
|
|
|
$$self{_BOLD} = $$term{_md} || "\e[1m"; |
|
41
|
0
|
|
0
|
|
|
|
$$self{_UNDL} = $$term{_us} || "\e[4m"; |
|
42
|
0
|
|
0
|
|
|
|
$$self{_NORM} = $$term{_me} || "\e[m"; |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$self; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Pod::Simple::Text::Termcap - Convert POD data to ASCII text with format escapes |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 VERSION |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Version 0.01 |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Convert POD data to ASCII text with format escapes |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
( my $pod_text = <<'__POD__' ) =~ s/^[ \t]+//mg; |
|
62
|
|
|
|
|
|
|
=head1 Some pod |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
F bla bla B |
|
65
|
|
|
|
|
|
|
Some more text |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
|
68
|
|
|
|
|
|
|
__POD__ |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# |
|
71
|
|
|
|
|
|
|
use Pod::Simple::Text::Termcap; |
|
72
|
|
|
|
|
|
|
my $parser = Pod::Simple::Text::Termcap->new; |
|
73
|
|
|
|
|
|
|
$parser->parse_string_document( $pod_text); |
|
74
|
|
|
|
|
|
|
$parser->output_string( \my $out ); |
|
75
|
|
|
|
|
|
|
print($out); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# use it as a filter |
|
79
|
|
|
|
|
|
|
use Pod::Simple::Text::Termcap; |
|
80
|
|
|
|
|
|
|
Pod::Simple::Text::Termcap->filter( \$pod_text ); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
C is a subclass of C. |
|
85
|
|
|
|
|
|
|
This module is just a drop in replacement for Pod::Simple::Text. |
|
86
|
|
|
|
|
|
|
C prints headlines and C<< BEE >> tags |
|
87
|
|
|
|
|
|
|
bold. C<< IEE >> and C<< FEE >> tags are underlined. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Thats all. Pretty close to what C do for C. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NOTES |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This module uses Term::Cap to retrieve the formatting escape sequences |
|
94
|
|
|
|
|
|
|
for the current terminal, and falls back on the ECMA-48 (the same in |
|
95
|
|
|
|
|
|
|
this regard as ANSI X3.64 and ISO 6429, the escape codes also used by |
|
96
|
|
|
|
|
|
|
DEC VT100 terminals) if the bold, underline, and reset codes aren't set |
|
97
|
|
|
|
|
|
|
in the termcap information. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
C, C, C, C |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 EXPORT |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Nothing |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Boris Zentner, C<< >> |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 BUGS |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
114
|
|
|
|
|
|
|
C, or through the web interface at |
|
115
|
|
|
|
|
|
|
L. |
|
116
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
117
|
|
|
|
|
|
|
your bug as I make changes. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Parts stolen from Russ Allbery's C. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Copyright 2005 Boris Zentner, All Rights Reserved. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
128
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; # End of Pod::Simple::Text::Termcap |