From: Russ Allbery Date: Mon, 25 Dec 2000 05:09:30 +0000 (-0800) Subject: podlators 1.06 released X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=738498554754dd90699c8e9143242cd60b1e5e37;p=p5sagit%2Fp5-mst-13.2.git podlators 1.06 released Message-ID: p4raw-id: //depot/perl@8259 --- diff --git a/MANIFEST b/MANIFEST index 1bf4b4a..7445fd7 100644 --- a/MANIFEST +++ b/MANIFEST @@ -719,6 +719,7 @@ lib/Pod/Plainer.pm Pod migration utility module lib/Pod/Select.pm Pod-Parser - select portions of POD docs lib/Pod/Text.pm Pod-Parser - convert POD data to formatted ASCII text lib/Pod/Text/Color.pm Convert POD data to color ASCII text +lib/Pod/Text/Overstrike.pm Convert POD data to formatted overstrike text lib/Pod/Text/Termcap.pm Convert POD data to ASCII text with format escapes lib/Pod/Usage.pm Pod-Parser - print usage messages lib/Search/Dict.pm Perform binary search on dictionaries diff --git a/lib/Pod/Man.pm b/lib/Pod/Man.pm index 3b96156..84c8f66 100644 --- a/lib/Pod/Man.pm +++ b/lib/Pod/Man.pm @@ -1,5 +1,5 @@ # Pod::Man -- Convert POD data to formatted *roff input. -# $Id: Man.pm,v 1.10 2000/11/19 05:46:19 eagle Exp $ +# $Id: Man.pm,v 1.12 2000/12/25 12:56:12 eagle Exp $ # # Copyright 1999, 2000 by Russ Allbery # @@ -38,7 +38,7 @@ use vars qw(@ISA %ESCAPES $PREAMBLE $VERSION); # 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.10; +$VERSION = 1.12; ############################################################################ @@ -1063,7 +1063,7 @@ sub output { print { $_[0]->output_handle } $_[1] } # If there are double quotes, use an if statement to test for nroff, and for # nroff output the command followed by the argument in double quotes with # embedded double quotes doubled. For other formatters, remap paired double -# quotes to `` and ''. +# quotes to LQUOTE and RQUOTE. sub switchquotes { my $self = shift; my $command = shift; @@ -1073,17 +1073,19 @@ sub switchquotes { # We also have to deal with \*C` and \*C', which are used to add the # quotes around C<> text, since they may expand to " and if they do this - # confuses the .SH macros and the like no end. + # confuses the .SH macros and the like no end. Expand them ourselves. + # If $extra is set, we're dealing with =item, which in most nroff macro + # sets requires an extra level of quoting of double quotes. my $c_is_quote = ($$self{LQUOTE} =~ /\"/) || ($$self{RQUOTE} =~ /\"/); if (/\"/ || ($c_is_quote && /\\\*\(C[\'\`]/)) { s/\"/\"\"/g; my $troff = $_; $troff =~ s/\"\"([^\"]*)\"\"/\`\`$1\'\'/g; - s/\"/\"\"/g if $extra; - $troff =~ s/\"/\"\"/g if $extra; s/\\\*\(C\`/$$self{LQUOTE}/g; s/\\\*\(C\'/$$self{RQUOTE}/g; $troff =~ s/\\\*\(C[\'\`]//g; + s/\"/\"\"/g if $extra; + $troff =~ s/\"/\"\"/g if $extra; $_ = qq("$_") . ($extra ? " $extra" : ''); $troff = qq("$troff") . ($extra ? " $extra" : ''); return ".if n $command $_\n.el $command $troff\n"; diff --git a/lib/Pod/Text/Color.pm b/lib/Pod/Text/Color.pm index 10e1d9f..e943216 100644 --- a/lib/Pod/Text/Color.pm +++ b/lib/Pod/Text/Color.pm @@ -1,5 +1,5 @@ # Pod::Text::Color -- Convert POD data to formatted color ASCII text -# $Id: Color.pm,v 0.5 1999/09/20 10:15:16 eagle Exp $ +# $Id: Color.pm,v 0.6 2000/12/25 12:52:39 eagle Exp $ # # Copyright 1999 by Russ Allbery # @@ -26,8 +26,11 @@ use vars qw(@ISA $VERSION); @ISA = qw(Pod::Text); -# Use the CVS revision of this file as its version number. -($VERSION = (split (' ', q$Revision: 0.5 $ ))[1]) =~ s/\.(\d)$/.0$1/; +# 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 = 0.06; ############################################################################ diff --git a/lib/Pod/Text/Overstrike.pm b/lib/Pod/Text/Overstrike.pm new file mode 100644 index 0000000..c9f0789 --- /dev/null +++ b/lib/Pod/Text/Overstrike.pm @@ -0,0 +1,160 @@ +# Pod::Text::Overstrike -- Convert POD data to formatted overstrike text +# $Id: Overstrike.pm,v 1.1 2000/12/25 12:51:23 eagle Exp $ +# +# Created by Joe Smith 30-Nov-2000 +# (based on Pod::Text::Color by Russ Allbery ) +# +# This program is free software; you can redistribute it and/or modify it +# under the same terms as Perl itself. +# +# This was written because the output from: +# +# pod2text Text.pm > plain.txt; less plain.txt +# +# is not as rich as the output from +# +# pod2man Text.pm | nroff -man > fancy.txt; less fancy.txt +# +# and because both Pod::Text::Color and Pod::Text::Termcap are not device +# independent. + +############################################################################ +# Modules and declarations +############################################################################ + +package Pod::Text::Overstrike; + +require 5.004; + +use Pod::Text (); + +use strict; +use vars qw(@ISA $VERSION); + +@ISA = qw(Pod::Text); + +# 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.01; + + +############################################################################ +# Overrides +############################################################################ + +# Make level one headings bold, overridding any existing formatting. +sub cmd_head1 { + my $self = shift; + local $_ = shift; + s/\s+$//; + s/(.)\cH\1//g; + s/_\cH//g; + s/(.)/$1\b$1/g; + $self->SUPER::cmd_head1 ($_); +} + +# Make level two headings bold, overriding any existing formatting. +sub cmd_head2 { + my $self = shift; + local $_ = shift; + s/\s+$//; + s/(.)\cH\1//g; + s/_\cH//g; + s/(.)/$1\b$1/g; + $self->SUPER::cmd_head2 ($_); +} + +# Make level three headings underscored, overriding any existing formatting. +sub cmd_head3 { + my $self = shift; + local $_ = shift; + s/\s+$//; + s/(.)\cH\1//g; + s/_\cH//g; + s/(.)/_\b$1/g; + $self->SUPER::cmd_head3 ($_); +} + +# Fix the various interior sequences. +sub seq_b { local $_ = $_[1]; s/(.)\cH\1//g; s/_\cH//g; s/(.)/$1\b$1/g; $_ } +sub seq_f { local $_ = $_[1]; s/(.)\cH\1//g; s/_\cH//g; s/(.)/_\b$1/g; $_ } +sub seq_i { local $_ = $_[1]; s/(.)\cH\1//g; s/_\cH//g; s/(.)/_\b$1/g; $_ } + +# We unfortunately have to override the wrapping code here, since the normal +# wrapping code gets really confused by all the escape sequences. +sub wrap { + my $self = shift; + local $_ = shift; + my $output = ''; + my $spaces = ' ' x $$self{MARGIN}; + my $width = $$self{width} - $$self{MARGIN}; + while (length > $width) { + if (s/^((?:(?:[^\n]\cH)?[^\n]){0,$width})\s+// + || s/^((?:(?:[^\n]\cH)?[^\n]){$width})//) { + $output .= $spaces . $1 . "\n"; + } else { + last; + } + } + $output .= $spaces . $_; + $output =~ s/\s+$/\n\n/; + $output; +} + +############################################################################ +# Module return value and documentation +############################################################################ + +1; +__END__ + +=head1 NAME + +Pod::Text::Overstrike - Convert POD data to formatted overstrike text + +=head1 SYNOPSIS + + use Pod::Text::Overstrike; + my $parser = Pod::Text::Overstrike->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::Overstrike is a simple subclass of Pod::Text that highlights +output text using overstrike sequences, in a manner similar to nroff. +Characters in bold text are overstruck (character, backspace, character) and +characters in underlined text are converted to overstruck underscores +(underscore, backspace, character). This format was originally designed for +hardcopy terminals and/or lineprinters, yet is readable on softcopy (CRT) +terminals. + +Overstruck text is best viewed by page-at-a-time programs that take +advantage of the terminal's B and I capabilities, such +as the less program on Unix. + +Apart from the overstrike, it in all ways functions like Pod::Text. See +L for details and available options. + +=head1 BUGS + +Currently, the outermost formatting instruction wins, so for example +underlined text inside a region of bold text is displayed as simply bold. +There may be some better approach possible. + +=head1 SEE ALSO + +L, L + +=head1 AUTHOR + +Joe Smith EJoe.Smith@inwap.comE, using the framework created by Russ +Allbery Erra@stanford.eduE. + +=cut diff --git a/lib/Pod/Text/Termcap.pm b/lib/Pod/Text/Termcap.pm index 7e89ec6..333852a 100644 --- a/lib/Pod/Text/Termcap.pm +++ b/lib/Pod/Text/Termcap.pm @@ -1,5 +1,5 @@ # Pod::Text::Termcap -- Convert POD data to ASCII text with format escapes. -# $Id: Termcap.pm,v 0.4 1999/09/20 10:17:45 eagle Exp $ +# $Id: Termcap.pm,v 1.0 2000/12/25 12:52:48 eagle Exp $ # # Copyright 1999 by Russ Allbery # @@ -27,8 +27,11 @@ use vars qw(@ISA $VERSION); @ISA = qw(Pod::Text); -# Use the CVS revision of this file as its version number. -($VERSION = (split (' ', q$Revision: 0.4 $ ))[1]) =~ s/\.(\d)$/.0$1/; +# 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; ############################################################################ diff --git a/pod/pod2text.PL b/pod/pod2text.PL index b4965cb..7b5727d 100644 --- a/pod/pod2text.PL +++ b/pod/pod2text.PL @@ -75,8 +75,8 @@ my %options; $options{sentence} = 0; Getopt::Long::config ('bundling'); GetOptions (\%options, 'alt|a', 'color|c', 'help|h', 'indent|i=i', - 'loose|l', 'quotes|q=s', 'sentence|s', 'termcap|t', - 'width|w=i') or exit 1; + 'loose|l', 'overstrike|o', 'quotes|q=s', 'sentence|s', + 'termcap|t', 'width|w=i') or exit 1; pod2usage (1) if $options{help}; # Figure out what formatter we're going to use. -c overrides -t. @@ -89,8 +89,11 @@ if ($options{color}) { } elsif ($options{termcap}) { $formatter = 'Pod::Text::Termcap'; require Pod::Text::Termcap; +} elsif ($options{overstrike}) { + $formatter = 'Pod::Text::Overstrike'; + require Pod::Text::Overstrike; } -delete @options{'color', 'termcap'}; +delete @options{'color', 'termcap', 'overstrike'}; # Initialize and run the formatter. my $parser = $formatter->new (%options); @@ -104,7 +107,7 @@ pod2text - Convert POD data to formatted ASCII text =head1 SYNOPSIS -pod2text [B<-aclst>] [B<-i> I] [B<-q> I] [B<-w> I] +pod2text [B<-aclost>] [B<-i> I] [B<-q> I] [B<-w> I] [I [I]] pod2text B<-h> @@ -150,6 +153,13 @@ printed after C<=head1>, although one is still printed after C<=head2>, because this is the expected formatting for manual pages; if you're formatting arbitrary text documents, using this option is recommended. +=item B<-o>, B<--overstrike> + +Format the output with overstruck printing. Bold text is rendered as +character, backspace, character. Italics and file names are rendered as +underscore, backspace, character. Many pagers, such as B, know how +to convert this to bold or underlined text. + =item B<-q> I, B<--quotes>=I Sets the quote marks used to surround CE> text to I. If