Skip Menu |

This queue is for tickets about the podlators CPAN distribution.

Report information
The Basics
Id: 51480
Status: resolved
Priority: 0/
Queue: podlators

People
Owner: Nobody in particular
Requestors: hull [...] snap.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.2.2
Fixed in: 2.3.0



Subject: Formatting characters in Pod::Text::Overstrike confuse =item width calc
When using Pod::Text::Overstrike and using formatting in =item text, the overstrike characters confuse the calculation of the item text width. I am attaching a script that demonstrates the bug and a patch to fix it. To fix a corresponding problem with Pod::Text::Color, that module should define a strip_format method.
Subject: Pod-Text-pm.diff
--- /usr/lib/perl5/5.10.0/Pod/Text.pm.orig 2009-11-12 11:03:12.000000000 -0800 +++ /usr/lib/perl5/5.10.0/Pod/Text.pm 2009-11-12 11:07:11.000000000 -0800 @@ -275,6 +275,8 @@ # Text blocks ############################################################################## +sub strip_format { return $_[1]; } + # This method is called whenever an =item command is complete (in other words, # we've seen its associated paragraph or know for certain that it doesn't have # one). It gets the paragraph associated with the item as an argument. If @@ -296,7 +298,8 @@ my $indent = $$self{INDENTS}[-1]; $indent = $$self{opt_indent} unless defined $indent; my $margin = ' ' x $$self{opt_margin}; - my $fits = ($$self{MARGIN} - $indent >= length ($tag) + 1); + my $tag_length = length($self->strip_format($tag)); + my $fits = ($$self{MARGIN} - $indent >= $tag_length + 1); # If the tag doesn't fit, or if we have no associated text, print out the # tag separately. Otherwise, put the tag in the margin of the paragraph. @@ -321,7 +324,7 @@ $space =~ s/^$margin /$margin:/ if $$self{opt_alt}; $text = $self->reformat ($text); $text =~ s/^$margin /$margin:/ if ($$self{opt_alt} && $indent > 0); - my $tagspace = ' ' x length $tag; + my $tagspace = ' ' x $tag_length; $text =~ s/^($space)$tagspace/$1$tag/ or warn "Bizarre space in item"; $self->output ($text); }
Subject: podtest
Download podtest
application/octet-stream 315b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #51480] Formatting characters in Pod::Text::Overstrike confuse =item width calc
Date: Wed, 02 Dec 2009 21:27:54 -0800
To: bug-podlators [...] rt.cpan.org
From: Russ Allbery <rra [...] stanford.edu>
"David Hull via RT" <bug-podlators@rt.cpan.org> writes: Show quoted text
> When using Pod::Text::Overstrike and using formatting in =item text, the > overstrike characters confuse the calculation of the item text width. > I am attaching a script that demonstrates the bug and a patch to fix it.
Thanks for the report! Now that you've pointed it out, I can see the problem. Your attached patch didn't include the Pod::Text::Overstrike modification to override strip_format. Could you send that? I can probably recreate it now that I see the problem, but it would save some time to have your existing work. Thanks! -- Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>
Subject: Re: [rt.cpan.org #51480] Formatting characters in Pod::Text::Overstrike confuse =item width calc
Date: Thu, 3 Dec 2009 09:27:27 -0800
To: bug-podlators [...] rt.cpan.org
From: David Hull <hull [...] snap.com>
On Thu, 03 Dec 2009 00:28:16 -0500, "rra@stanford.edu via RT" <bug-podlators@rt.cpan.org> wrote: Show quoted text
> Your attached patch didn't include the Pod::Text::Overstrike > modification to override strip_format. Could you send that?
Pod::Text::Overstrike already defines a strip_format function, which doesn't need any modification, so the only change necessary is the patch to Pod::Text. To fix Pod::Text::Color, a strip_format function does need to be added. Something like the following should work: --- /usr/lib/perl5/5.10.0/Pod/Text/Color.pm.orig 2009-12-03 09:21:14.000000000 -0800 +++ /usr/lib/perl5/5.10.0/Pod/Text/Color.pm 2009-12-03 09:21:52.000000000 -0800 @@ -54,6 +54,12 @@ sub cmd_f { return colored ($_[2], 'cyan') } sub cmd_i { return colored ($_[2], 'yellow') } +sub strip_format { + my ($self, $text) = @_; + $text =~ s/\e\[[\d;]*m//g; + return $text; +} + # Output any included code in green. sub output_code { my ($self, $code) = @_; -- David Hull
Subject: Re: [rt.cpan.org #51480] Formatting characters in Pod::Text::Overstrike confuse =item width calc
Date: Fri, 04 Dec 2009 16:22:26 -0800
To: bug-podlators [...] rt.cpan.org
From: Russ Allbery <rra [...] stanford.edu>
"David Hull via RT" <bug-podlators@rt.cpan.org> writes: Show quoted text
> Pod::Text::Overstrike already defines a strip_format function, which > doesn't need any modification, so the only change necessary is the patch > to Pod::Text.
Show quoted text
> To fix Pod::Text::Color, a strip_format function does need to be added. > Something like the following should work:
Oh! Sorry, I didn't look deeply enough. I understand now. I'll definitely incorporate this in the next release. -- Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>
Fixed in podlators 2.3.0, just released.