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: 4874
Status: new
Priority: 0/
Queue: HTML-FromText

People
Owner: Nobody in particular
Requestors: slaven [...] rezic.de
Cc:
AdminCc:

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

Attachments


Subject: Numbered lists interrupted by paragraphs
Download (untitled) / with headers
text/plain 363b
The attached patch makes it possible to turn something like: 1 One 2 Two Normal text 3 Three 4 Four into correct-looking html by using the start="3" attribute in the second <ol> list. However, the start attribute is deprecated in HTML 4.01 and an alternative implementation using CSS (by using custom counters) seems to be complicated. Regards, Slaven
# # # To apply this patch: # STEP 1: Chdir to the source directory. # STEP 2: Run the 'applypatch' program with this patch file as input. # # If you do not have 'applypatch', it is part of the 'makepatch' package # that you can fetch from the Comprehensive Perl Archive Network: # http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz # In the above URL, 'x' should be 2 or higher. # # To apply this patch without the use of 'applypatch': # STEP 1: Chdir to the source directory. # STEP 2: Run the 'patch' program with this file as input. # #### End of Preamble #### #### Patch data follows #### diff -up '/usr/local/dist/cpan/build/HTML-FromText-2.05/lib/HTML/FromText.pm' 'HTML-FromText-2.05/lib/HTML/FromText.pm' Index: ./lib/HTML/FromText.pm --- ./lib/HTML/FromText.pm Tue Oct 14 02:16:10 2003 +++ ./lib/HTML/FromText.pm Thu Jan 8 16:52:15 2004 @@ -474,7 +474,7 @@ Return value is ignored. sub numbers { my ($self) = @_; - $self->_format_list( qr/[0-9]/, 'ol', 'hft-numbers'); + $self->_format_list( qr/[0-9]+/, 'ol', 'hft-numbers'); } =head3 tables @@ -672,18 +672,20 @@ sub _carp { } sub _format_list { - my ($self, $identifier, $parent, $class) = @_; + my ($self, $identifier_rx, $parent, $class) = @_; $self->_manipulate_paras(sub { my ($text) = @_; - return unless $text =~ m[^\s*($identifier)\s+]; + return unless $text =~ m[^\s*($identifier_rx)\s+]; my ($pos, $html, @open) = (-1, ''); - foreach my $line ( split /\n(?=\s*$identifier)/, $text ) { - $line =~ s[(\s*)$identifier][]; + foreach my $line ( split /\n(?=\s*$identifier_rx)/, $text ) { + $line =~ s[(\s*)($identifier_rx)][]; my $line_pos = length $1; + my $identifier = $2; if ($line_pos > $pos) { - $html .= (' ' x $line_pos) . qq[<$parent class="$class">\n]; + my $start = $parent eq 'ol' && $identifier != 1 ? qq[ start="$identifier"] : ""; + $html .= (' ' x $line_pos) . qq[<$parent$start class="$class">\n]; push @open, $line_pos; } elsif ($line_pos < $pos) { until ( $open[-1] <= $line_pos ) { diff -up '/usr/local/dist/cpan/build/HTML-FromText-2.05/t/01_features.t' 'HTML-FromText-2.05/t/01_features.t' Index: ./t/01_features.t --- ./t/01_features.t Tue Oct 14 01:24:24 2003 +++ ./t/01_features.t Thu Jan 8 16:51:06 2004 @@ -159,6 +159,32 @@ cmp_ok( $html, 'eq', <<__HTML__, 'nested <p class="hft-paras">Normal Text</p> __HTML__ +$t2h = HTML::FromText->new({paras => 1, numbers => 1}); +$html = $t2h->parse( <<__TEXT__ ); +1 One +2 Two + +Normal Text + +3 Three +4 Four +5 Five +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'numbered list interrupted by paragraph' ); +<ol class="hft-numbers"> +<li> One</li> +<li> Two</li> +</ol> + +<p class="hft-paras">Normal Text</p> + +<ol start="3" class="hft-numbers"> +<li> Three</li> +<li> Four</li> +<li> Five</li> +</ol> +__HTML__ + $t2h = HTML::FromText->new({paras => 1, headings => 1}); $html = $t2h->parse( <<__TEXT__ ); 1. One #### End of Patch data #### #### ApplyPatch data follows #### # Data version : 1.0 # Date generated : Thu Jan 8 16:57:47 2004 # Generated by : makepatch 2.00_07* # Recurse directories : Yes # Excluded files : (\A|/).*\~\Z # (\A|/).*\.a\Z # (\A|/).*\.bak\Z # (\A|/).*\.BAK\Z # (\A|/).*\.elc\Z # (\A|/).*\.exe\Z # (\A|/).*\.gz\Z # (\A|/).*\.ln\Z # (\A|/).*\.o\Z # (\A|/).*\.obj\Z # (\A|/).*\.olb\Z # (\A|/).*\.old\Z # (\A|/).*\.orig\Z # (\A|/).*\.rej\Z # (\A|/).*\.so\Z # (\A|/).*\.Z\Z # (\A|/)\.del\-.*\Z # (\A|/)\.make\.state\Z # (\A|/)\.nse_depinfo\Z # (\A|/)core\Z # (\A|/)tags\Z # (\A|/)TAGS\Z # p 'lib/HTML/FromText.pm' 20704 1073577135 0100644 # p 't/01_features.t' 7709 1073577066 0100755 #### End of ApplyPatch data #### #### End of Patch kit [created: Thu Jan 8 16:57:47 2004] #### #### Patch checksum: 111 3786 58818 #### #### Checksum: 129 4411 44871 ####


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.