1 # Pod::Text::Overstrike -- Convert POD data to formatted overstrike text
2 # $Id: Overstrike.pm,v 1.1 2000/12/25 12:51:23 eagle Exp $
4 # Created by Joe Smith <Joe.Smith@inwap.com> 30-Nov-2000
5 # (based on Pod::Text::Color by Russ Allbery <rra@stanford.edu>)
7 # This program is free software; you can redistribute it and/or modify it
8 # under the same terms as Perl itself.
10 # This was written because the output from:
12 # pod2text Text.pm > plain.txt; less plain.txt
14 # is not as rich as the output from
16 # pod2man Text.pm | nroff -man > fancy.txt; less fancy.txt
18 # and because both Pod::Text::Color and Pod::Text::Termcap are not device
21 ############################################################################
22 # Modules and declarations
23 ############################################################################
25 package Pod::Text::Overstrike;
32 use vars qw(@ISA $VERSION);
36 # Don't use the CVS revision as the version, since this module is also in
37 # Perl core and too many things could munge CVS magic revision strings.
38 # This number should ideally be the same as the CVS revision in podlators,
43 ############################################################################
45 ############################################################################
47 # Make level one headings bold, overridding any existing formatting.
55 $self->SUPER::cmd_head1 ($_);
58 # Make level two headings bold, overriding any existing formatting.
66 $self->SUPER::cmd_head2 ($_);
69 # Make level three headings underscored, overriding any existing formatting.
77 $self->SUPER::cmd_head3 ($_);
80 # Fix the various interior sequences.
81 sub seq_b { local $_ = $_[1]; s/(.)\cH\1//g; s/_\cH//g; s/(.)/$1\b$1/g; $_ }
82 sub seq_f { local $_ = $_[1]; s/(.)\cH\1//g; s/_\cH//g; s/(.)/_\b$1/g; $_ }
83 sub seq_i { local $_ = $_[1]; s/(.)\cH\1//g; s/_\cH//g; s/(.)/_\b$1/g; $_ }
85 # We unfortunately have to override the wrapping code here, since the normal
86 # wrapping code gets really confused by all the escape sequences.
91 my $spaces = ' ' x $$self{MARGIN};
92 my $width = $$self{width} - $$self{MARGIN};
93 while (length > $width) {
94 if (s/^((?:(?:[^\n]\cH)?[^\n]){0,$width})\s+//
95 || s/^((?:(?:[^\n]\cH)?[^\n]){$width})//) {
96 $output .= $spaces . $1 . "\n";
101 $output .= $spaces . $_;
102 $output =~ s/\s+$/\n\n/;
106 ############################################################################
107 # Module return value and documentation
108 ############################################################################
115 Pod::Text::Overstrike - Convert POD data to formatted overstrike text
119 use Pod::Text::Overstrike;
120 my $parser = Pod::Text::Overstrike->new (sentence => 0, width => 78);
122 # Read POD from STDIN and write to STDOUT.
123 $parser->parse_from_filehandle;
125 # Read POD from file.pod and write to file.txt.
126 $parser->parse_from_file ('file.pod', 'file.txt');
130 Pod::Text::Overstrike is a simple subclass of Pod::Text that highlights
131 output text using overstrike sequences, in a manner similar to nroff.
132 Characters in bold text are overstruck (character, backspace, character) and
133 characters in underlined text are converted to overstruck underscores
134 (underscore, backspace, character). This format was originally designed for
135 hardcopy terminals and/or lineprinters, yet is readable on softcopy (CRT)
138 Overstruck text is best viewed by page-at-a-time programs that take
139 advantage of the terminal's B<stand-out> and I<underline> capabilities, such
140 as the less program on Unix.
142 Apart from the overstrike, it in all ways functions like Pod::Text. See
143 L<Pod::Text> for details and available options.
147 Currently, the outermost formatting instruction wins, so for example
148 underlined text inside a region of bold text is displayed as simply bold.
149 There may be some better approach possible.
153 L<Pod::Text|Pod::Text>, L<Pod::Parser|Pod::Parser>
157 Joe Smith E<lt>Joe.Smith@inwap.comE<gt>, using the framework created by Russ
158 Allbery E<lt>rra@stanford.eduE<gt>.