I ran into yet another problem with html.pm and had to take a bit of sledge-hammer to our friend 'clean_data'. At any rate, the new version looks like:
# # coalesce: concatenate paragraphs that should be contiguous # sub coalesce { # hsm 10/11/01 my $array = shift; # hsm 10/11/01 my $i = shift; # hsm 10/11/01 my $n = $#{$array}; # hsm 10/11/01 ${$array}[$i++] .= ${$array}[$i]; # hsm 10/11/01 splice(@{$array},$i,1,@{$array}[($i + 1)..$n--]); # hsm 10/11/01 $#{$array} = $n; # hsm 10/11/01 } # hsm 10/11/01 # # clean_data: global clean-up of pod data # sub clean_data($) { my ($dataref) = @_; my $i; for ( $i = 0 ; $i <= $#$dataref ; $i++ ) { if (${$dataref}[$i] =~ /^=begin html/i) { # hsm 10/11/01 while (${$dataref}[$i + 1] !~ /^=end html/i) { # hsm 10/11 +/01 coalesce($dataref,$i); # hsm 10/11/01 } # hsm 10/11/01 } # hsm 10/11/01 if(${$dataref}[$i] =~ s/([^\x0a])\x0a=/$1\x00=/g) { # hsm 10/9 +/01 my @otherchunks = split ( /\x00/m,${$dataref}[$i]); # hsm +10/9/01 splice( @$dataref, $i, 1, @otherchunks ); # hsm 10/9/01 redo; # hsm 10/9/01 } # hsm 10/9/01 ${$dataref}[$i] =~ s/\s+\Z//; # have a look for all-space lines if (${$dataref}[$i] =~ /^\s+$/m and ${$dataref}[$i] !~ /^\s/ ) + { my @chunks = split ( /^\s+$/m, ${$dataref}[$i] ); splice( @$dataref, $i, 1, @chunks ); } } }
Still no particular magic, unless slight-of-hand counts<g>! The second problem was the loss of "\n\n" lines within <larger>=begin html/=end html</larger> commands. This is caused by the notion that the POD paragraph definitions hold within what amounts to an html block. It seems to me that you are far safer parsing this as an unbreakable unit of text, stopping only when you run into the next <larger>=end html</larger> marker. This implementation is naive in that I don't allow arbitrarily nested = commands within the html text. It begins to look like this might well require a major re-write, something that doesn't make much sense given the existence of Pod::Parser. I'm going to think about it some more before I figure out which way to go.
hsm<smaller>whose handle in prep school was—you guessed it! Hubris</smaller>
In reply to Bugs, Patches and Hubris by hsmyers
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |