Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the HTML-FromText CPAN distribution.

Report information
The Basics
Id: 9021
Status: new
Priority: 0/
Queue: HTML-FromText

People
Owner: Nobody in particular
Requestors: stig [...] brautaset.org
Cc:
AdminCc:

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



Subject: regex to detect paragraphs only considers \n line endings
Version 2.05 of this module does not recognise paragraphs if \r\n (or \r) is used for line endings. It separates paragraps that are separated by two \n only. This is a regression from the latest 1.x version. The below patch fixes the problem for me. --- FromText.pm.orig 2004-12-04 20:02:11.000000000 +0000 +++ FromText.pm 2004-12-04 20:03:30.000000000 +0000 @@ -403,7 +403,7 @@ my ($self) = @_; my $options = $self->{options}; - my @paras = split /\n{2,}/, $self->{html}; + my @paras = split /(?:\n|\r\n|\r){2,}/, $self->{html}; my %paras = map { $_, { text => $paras[$_], html => undef } } 0 .. $#paras; $self->{paras} = \%paras;
Here is a better patch, including test for the (hopefully ;) upcoming release: diff -Naur HTML-FromText-2.05.orig/lib/HTML/FromText.pm HTML-FromText-2.05.mod/ lib/HTML/FromText.pm --- HTML-FromText-2.05.orig/lib/HTML/FromText.pm 2003-10-14 01:16: 10.000000000 +0100 +++ HTML-FromText-2.05.mod/lib/HTML/FromText.pm 2005-01-26 16:19:22.000000000 +0000 @@ -403,7 +403,7 @@ my ($self) = @_; my $options = $self->{options}; - my @paras = split /\n{2,}/, $self->{html}; + my @paras = split /(?:\n{2,}|(?:\r\n){2,}|\r{2,})/, $self->{html}; my %paras = map { $_, { text => $paras[$_], html => undef } } 0 .. $#paras; $self->{paras} = \%paras; diff -Naur HTML-FromText-2.05.orig/MANIFEST HTML-FromText-2.05.mod/MANIFEST --- HTML-FromText-2.05.orig/MANIFEST 2003-10-14 01:17:44.000000000 +0100 +++ HTML-FromText-2.05.mod/MANIFEST 2005-01-26 16:22:05.000000000 +0000 @@ -13,5 +13,6 @@ t/04_v2.03.t t/05_v2.04.t t/06_v2.05.t +t/07_v2.06.t t/99_pod.t t/files/paras.txt diff -Naur HTML-FromText-2.05.orig/t/07_v2.06.t HTML-FromText-2.05.mod/t/07_v2.06.t --- HTML-FromText-2.05.orig/t/07_v2.06.t 1970-01-01 01:00:00.000000000 +0100 +++ HTML-FromText-2.05.mod/t/07_v2.06.t 2005-01-26 16:20:34.000000000 +0000 @@ -0,0 +1,21 @@ +use Test::More qw[no_plan]; + +use_ok 'HTML::FromText'; + +my $html = text2html( <<"__TEXT__", paras => 1 ); +One\r\n\r\nTwo +__TEXT__ +cmp_ok( $html, 'eq', <<'__HTML__', 'two paras with windows newlines' ); +<p class="hft-paras">One</p> + +<p class="hft-paras">Two</p> +__HTML__ + +$html = text2html( <<"__TEXT__", paras => 1 ); +One\r\rTwo +__TEXT__ +cmp_ok( $html, 'eq', <<'__HTML__', 'two paras with mac newlines' ); +<p class="hft-paras">One</p> + +<p class="hft-paras">Two</p> +__HTML__