Termcap.pm revision 7c478bd95313f5f23a4c958a745db2134aa03244
# Pod::Text::Termcap -- Convert POD data to ASCII text with format escapes.
# $Id: Termcap.pm,v 1.0 2000/12/25 12:52:48 eagle Exp $
#
# Copyright 1999 by Russ Allbery <rra@stanford.edu>
#
# under the same terms as Perl itself.
#
# This is a simple subclass of Pod::Text that overrides a few key methods to
# output the right termcap escape sequences for formatted text on the
# current terminal type.
############################################################################
# Modules and declarations
############################################################################
require 5.004;
use POSIX ();
use strict;
# Don't use the CVS revision as the version, since this module is also in
# Perl core and too many things could munge CVS magic revision strings.
# This number should ideally be the same as the CVS revision in podlators,
# however.
$VERSION = 1.00;
############################################################################
# Overrides
############################################################################
# In the initialization method, grab our terminal characteristics as well as
# do all the stuff we normally do.
sub initialize {
my $self = shift;
# The default Term::Cap path won't work on Solaris.
}
}
# Make level one headings bold.
sub cmd_head1 {
my $self = shift;
local $_ = shift;
s/\s+$//;
}
# Make level two headings bold.
sub cmd_head2 {
my $self = shift;
local $_ = shift;
s/\s+$//;
}
# Fix up B<> and I<>. Note that we intentionally don't do F<>.
# Override the wrapping code to igore the special sequences.
sub wrap {
my $self = shift;
local $_ = shift;
my $output = '';
my $code = "(?:\Q$$self{BOLD}\E|\Q$$self{UNDL}\E|\Q$$self{NORM}\E)";
while (length > $width) {
} else {
last;
}
}
$output =~ s/\s+$/\n\n/;
$output;
}
############################################################################
# Module return value and documentation
############################################################################
1;
=head1 NAME
Pod::Text::Color - Convert POD data to ASCII text with format escapes
=head1 SYNOPSIS
use Pod::Text::Termcap;
my $parser = Pod::Text::Termcap->new (sentence => 0, width => 78);
# Read POD from STDIN and write to STDOUT.
$parser->parse_from_filehandle;
# Read POD from file.pod and write to file.txt.
$parser->parse_from_file ('file.pod', 'file.txt');
=head1 DESCRIPTION
Pod::Text::Termcap is a simple subclass of Pod::Text that highlights output
text using the correct termcap escape sequences for the current terminal.
Apart from the format codes, it in all ways functions like Pod::Text. See
L<Pod::Text> for details and available options.
=head1 SEE ALSO
L<Pod::Text|Pod::Text>, L<Pod::Parser|Pod::Parser>
=head1 AUTHOR
Russ Allbery E<lt>rra@stanford.eduE<gt>.
=cut