develooper Front page | perl.perl5.porters | Postings from February 2000

[5.5.660] Pod::Parser whitespace complaints

Thread Next
From:
Hugo
Date:
February 24, 2000 07:28
Subject:
[5.5.660] Pod::Parser whitespace complaints
Message ID:
200002241533.PAA06764@crypt.compulink.co.uk
Pod::Parser complains about whitespace on otherwise blank lines even
when they are within non-pod areas. Whitespace should be perfectly
legal in code, and is sometimes even necessary (eg within strings).

I'm not entirely sure how to fix this, since it requires lookahead on
the input stream: perhaps the answer is to read a true paragraph
first, then split on whitespace-only lines (with possible warning)
for processing.

Below is a partial patch attempting to implement that, but it doesn't
seem quite right, and doesn't yet check for whether a warning is
required in this case: that may be as simple as
  if ($head =~ /^=/ || $paragraph =~ /^=/) { ... }
.. but I'm not sure.

Hugo
--- lib/Pod/Parser.pm.old	Tue Feb 22 10:40:11 2000
+++ lib/Pod/Parser.pm	Thu Feb 24 15:23:43 2000
@@ -1059,17 +1059,21 @@
 
         ## See if this line is blank and ends the current paragraph.
         ## If it isnt, then keep iterating until it is.
-        next unless (($textline =~ /^(\s*)$/) && (length $paragraph));
+        next unless (($textline =~ /^$/) && (length $paragraph));
 
         ## Issue a warning about any non-empty blank lines
-        if ( length($1) > 1 ) {
+        while ($paragraph =~ /(.*)^[ \t]+\n(.*)/) {
+            (my $head, $paragraph) = ($1, $2);
+            my $eline = $nlines - ($paragraph =~ tr/\n/\n/);
             my $errorsub = $self->errorsub();
             my $file = $self->input_file();
             my $errmsg = "*** WARNING: line containing nothing but whitespace".
-                         " in paragraph at line $nlines in file $file\n";
+                         " in paragraph at line $eline in file $file\n";
             (ref $errorsub) and &{$errorsub}($errmsg)
                 or (defined $errorsub) and $self->$errorsub($errmsg)
                     or  warn($errmsg);
+            parse_paragraph($self, $head, ($nlines - $plines) + 1);
+            $plines = $nlines - $eline;
         }
 
         ## Now process the paragraph

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About