summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Vandiver <alexmv@mit.edu>2008-10-22 01:08:17 -0400
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-12-25 19:42:59 +0100
commitcaa547d451d5acc0894dc1770ed715cdaab20381 (patch)
tree2a13a871a4ce214b36817c21e4373677c93c6200
parent7a21560e6db00d9523852707b381ad4dd45a8b81 (diff)
downloadperl-caa547d451d5acc0894dc1770ed715cdaab20381.tar.gz
Blank lines "between" verbatim sections are now acceptible; This allows code examples to have indented blank lines without Pod::Parser carping.
-rw-r--r--lib/Pod/Parser.pm31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/Pod/Parser.pm b/lib/Pod/Parser.pm
index d242a516af..1f4a33d5b3 100644
--- a/lib/Pod/Parser.pm
+++ b/lib/Pod/Parser.pm
@@ -990,18 +990,38 @@ sub parse_paragraph {
# ## (invoke_callbacks will return true if we do).
# return 1 unless $self->invoke_callbacks($cmd, $text, $line_num, $pod_para);
# }
+
+ # If the last paragraph ended in whitespace, and we're not between verbatim blocks, carp
+ if ($myData{_WHITESPACE} and $myOpts{'-warnings'}
+ and not ($text =~ /^\s+/ and ($myData{_PREVIOUS}||"") eq "verbatim")) {
+ my $errorsub = $self->errorsub();
+ my $line = $line_num - 1;
+ my $errmsg = "*** WARNING: line containing nothing but whitespace".
+ " in paragraph at line $line in file $myData{_INFILE}\n";
+ (ref $errorsub) and &{$errorsub}($errmsg)
+ or (defined $errorsub) and $self->$errorsub($errmsg)
+ or warn($errmsg);
+ }
+
if (length $cmd) {
## A command paragraph
$self->command($cmd, $text, $line_num, $pod_para);
+ $myData{_PREVIOUS} = $cmd;
}
elsif ($text =~ /^\s+/) {
## Indented text - must be a verbatim paragraph
$self->verbatim($text, $line_num, $pod_para);
+ $myData{_PREVIOUS} = "verbatim";
}
else {
## Looks like an ordinary block of text
$self->textblock($text, $line_num, $pod_para);
+ $myData{_PREVIOUS} = "textblock";
}
+
+ # Update the whitespace for the next time around
+ $myData{_WHITESPACE} = $text =~ /^[^\S\r\n]+\Z/m ? 1 : 0;
+
return 1;
}
@@ -1083,17 +1103,6 @@ sub parse_from_filehandle {
next unless (($textline =~ /^([^\S\r\n]*)[\r\n]*$/)
&& (length $paragraph));
- ## Issue a warning about any non-empty blank lines
- if (length($1) > 0 and $myOpts{'-warnings'} and ! $myData{_CUTTING}) {
- 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";
- (ref $errorsub) and &{$errorsub}($errmsg)
- or (defined $errorsub) and $self->$errorsub($errmsg)
- or warn($errmsg);
- }
-
## Now process the paragraph
parse_paragraph($self, $paragraph, ($nlines - $plines) + 1);
$paragraph = '';