Skip Menu |

This queue is for tickets about the Text-WikiFormat CPAN distribution.

Report information
The Basics
Id: 1455
Status: resolved
Worked: 45 min
Priority: 0/
Queue: Text-WikiFormat

People
Owner: chromatic [...] cpan.org
Requestors: deus_x [...] pobox.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.4
Fixed in: (no value)



Subject: Error when text has leading newlines
I tried to format text which began with newlines and received the following error: Can't use an undefined value as an ARRAY reference at /home/deusx/lib/perl/Text/WikiFormat.pm line 142. This is what I did to fix it: 142c142 < return '' unless @{ $lists->{$active} }; --- Show quoted text
> return '' unless ( (ref($lists->{$active}) eq 'ARRAY') && @{ $lists->{$active} } );
Cheers :)
[DEUSX - Sun Aug 18 21:12:32 2002]: Show quoted text
> This is what I did to fix it: > > 142c142 > < return '' unless @{ $lists->{$active} }; > ---
> > return '' unless ( (ref($lists->{$active}) eq 'ARRAY') && @{
> $lists->{$active} } );
That's a genuine bug indeed. I think a better solution is not to call end_list() if there is no active list. Please try the attached patch and see if that cures it. (It works with my test case.) Thanks for the report, -- c
--- lib/Text/WikiFormat.pm~ Sat Aug 24 16:25:38 2002 +++ lib/Text/WikiFormat.pm Sat Aug 24 16:25:43 2002 @@ -121,7 +121,7 @@ if ($active_list and $active_list ne 'paragraph' or !$line) { pop @{ $lists{paragraph} } unless $line; $parsed .= end_list(\%lists, $active_list, - $tags{$active_list}); + $tags{$active_list}) if @{ $lists{paragraph} }; } next unless $line; --- /dev/null Thu Aug 30 02:54:37 2001 +++ t/bugs.t Sat Aug 24 16:29:56 2002 @@ -0,0 +1,21 @@ +#!/usr/bin/perl -w + +use strict; + +BEGIN { + chdir 't' if -d 't'; + unshift @INC, '../lib'; +} + +use Test::More tests => 2; + +use_ok( 'Text::WikiFormat' ); + +my $wikitext =<<WIKI; + +'''hello''' +WIKI + +my $htmltext = eval { Text::WikiFormat::format($wikitext) }; +is( $@, '', + 'format() should throw no warnings for text starting with newlines' );
From: kake [...] earth.li
[CHROMATIC - Sat Aug 24 19:34:04 2002]: Show quoted text
> Please try the attached patch and see if that cures it. (It works > with my test case.)
Your patch seems to introduce another bug which stops lists that are followed by paragraphs from being included in the formatted input. Different patch and test attached. Kake
--- lib/Text/WikiFormat.pm~ 2002-09-02 09:49:22.000000000 +0100 +++ lib/Text/WikiFormat.pm 2002-09-02 09:50:32.000000000 +0100 @@ -121,7 +121,7 @@ sub format { if ($active_list and $active_list ne 'paragraph' or !$line) { pop @{ $lists{paragraph} } unless $line; $parsed .= end_list(\%lists, $active_list, - $tags{$active_list}); + $tags{$active_list}) if $active_list; } next unless $line; --- /dev/null 2002-07-30 14:27:09.000000000 +0100 +++ t/bugs.t 2002-09-02 09:56:24.000000000 +0100 @@ -0,0 +1,29 @@ +#!/usr/bin/perl -w + +use strict; + +BEGIN { + chdir 't' if -d 't'; + unshift @INC, '../lib'; +} + +use Test::More tests => 3; + +use_ok( 'Text::WikiFormat' ); + +my $wikitext =<<WIKI; + + + * unordered + +Final paragraph. + +WIKI + +my $htmltext = eval { Text::WikiFormat::format($wikitext) }; + +is( $@, '', + 'format() should throw no warnings for text starting with newlines' ); + +like( $htmltext, qr!<li>unordered</li>!, + 'ensure that lists followed by paragraphs are included correctly' );
[guest - Mon Sep 2 05:09:07 2002]: Show quoted text
> Your patch seems to introduce another bug which stops lists that are > followed by paragraphs from being included in the formatted input. > Different patch and test attached.
Thanks, applied! This will be in version 0.45.