# Pod::Text::Overstrike -- Convert POD data to formatted overstrike text
-# $Id: Overstrike.pm,v 1.5 2001/11/23 09:57:15 eagle Exp $
+# $Id: Overstrike.pm,v 1.8 2002/02/17 04:38:03 eagle Exp $
#
# Created by Joe Smith <Joe.Smith@inwap.com> 30-Nov-2000
# (based on Pod::Text::Color by Russ Allbery <rra@stanford.edu>)
# 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.05;
+$VERSION = 1.08;
##############################################################################
$self->output (' ' x $indent . $text . "\n");
}
-# Fix the various interior sequences.
+# Fix the various formatting codes.
sub seq_b { local $_ = strip_format (@_); s/(.)/$1\b$1/g; $_ }
sub seq_f { local $_ = strip_format (@_); s/(.)/_\b$1/g; $_ }
sub seq_i { local $_ = strip_format (@_); 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.
+# wrapping code gets really confused by all the backspaces.
sub wrap {
my $self = shift;
local $_ = shift;
my $spaces = ' ' x $$self{MARGIN};
my $width = $$self{width} - $$self{MARGIN};
while (length > $width) {
- if (s/^((?:(?:[^\n]\cH)?[^\n]){0,$width})(\Z|\s+)//
- || s/^((?:(?:[^\n]\cH)?[^\n]){$width})//) {
+ # This regex represents a single character, that's possibly underlined
+ # or in bold (in which case, it's three characters; the character, a
+ # backspace, and a character). Use [^\n] rather than . to protect
+ # against odd settings of $*.
+ my $char = '(?:[^\n][\b])?[^\n]';
+ if (s/^((?>$char){0,$width})(?:\Z|\s+)//) {
$output .= $spaces . $1 . "\n";
} else {
last;
# version.
sub strip_format {
my ($self, $text) = @_;
- $text =~ s/(.)\cH\1/$1/g;
- $text =~ s/_\cH//g;
+ $text =~ s/(.)[\b]\1/$1/g;
+ $text =~ s/_[\b]//g;
return $text;
}