attempt to add whitespace warning

[email protected] (Michael Stevens)
Newsgroups perl.pod-people
Message-ID <[email protected]>
Hi.

The attached patch tries to add the whitespace on empty line warning
from Pod::Parser to Pod::Simple.

I suspect this may need discussion, and may even be completely wrong! So
submitting here rather than github or a job.

Michael
0001-Add-whitespace-on-empty-line-warning.patch (text/x-diff, 4.3 KB)
From f180a9bf6b05b5a94ba25430fb31436b4cc782f2 Mon Sep 17 00:00:00 2001
From: Michael Stevens <[email protected]>
Date: Sat, 12 Feb 2011 21:21:54 +0000
Subject: [PATCH] Add whitespace on empty line warning.

---
 lib/Pod/Simple/BlackBox.pm |    4 ++++
 t/corpus/fet_dup.txt       |    4 ++--
 t/corpus/koi8r.txt         |    4 ++--
 t/corpus/whitespace.txt    |    9 +++++++++
 t/corpus/whitespace.xml    |   29 +++++++++++++++++++++++++++++
 t/html01.t                 |    4 ++--
 6 files changed, 48 insertions(+), 6 deletions(-)
 create mode 100644 t/corpus/whitespace.txt
 create mode 100644 t/corpus/whitespace.xml

diff --git a/lib/Pod/Simple/BlackBox.pm b/lib/Pod/Simple/BlackBox.pm
index d90ea79..aab3bbd 100644
--- a/lib/Pod/Simple/BlackBox.pm
+++ b/lib/Pod/Simple/BlackBox.pm
@@ -202,6 +202,10 @@ sub parse_lines {             # Usage: $parser->parse_lines(@lines)
       }
       
       $self->{'last_was_blank'} = 1;
+	  
+	  if ($line =~ m/^\s+$/s and @$paras and $paras->[-1][0] ne "~Verbatim") {
+	  	$self->whine($self->{'line_count'}, "line containing nothing but whitespace");
+	  } 
       
     } elsif($self->{'last_was_blank'}) {  # A non-blank line starting a new para...
       
diff --git a/t/corpus/fet_dup.txt b/t/corpus/fet_dup.txt
index e8552e7..6485594 100644
--- a/t/corpus/fet_dup.txt
+++ b/t/corpus/fet_dup.txt
@@ -16,12 +16,12 @@ This should generate no errata.
 çÄÅ ÓÅÒÄÃÁ Ú×ÕÞÎÙÊ ÐÙÌ ÓÉÑÎØÅ ÌØÅÔ ËÒÕÇÏÍ /
 é ÓÔÒÁÓÔÉ ÒÏËÏ×ÏÊ ×ÚÄÙÍÁÀÔÓÑ ÐÏÔÏËÉ,- /
       îÅ ×ÓÐÏÍÎÉÌÁ ÌØ Ï ÞÅÍ?
-      
+
 ñ ×ÅÒÉÔØ ÎÅ ÈÏÞÕ! ëÏÇÄÁ × ÓÔÅÐÉ, ËÁË ÄÉ×Ï, /
 ÷ ÐÏÌÎÏÞÎÏÊ ÔÅÍÎÏÔÅ ÂÅÚ×ÒÅÍÅÎÎÏ ÇÏÒÑ, /
 ÷ÄÁÌÉ ÐÅÒÅÄ ÔÏÂÏÊ ÐÒÏÚÒÁÞÎÏ É ËÒÁÓÉ×Ï /
       ÷ÓÔÁ×ÁÌÁ ×ÄÒÕÇÚÁÒÑ.
-      
+
 é × ÜÔÕ ËÒÁÓÏÔÕ ÎÅ×ÏÌØÎÏ ×ÚÏÒ ÔÑÎÕÌÏ, /
 ÷ ÔÏÔ ×ÅÌÉÞÁ×ÙÊ ÂÌÅÓË ÚÁ ÔÅÍÎÙÊ ×ÅÓØ ÐÒÅÄÅÌ,- /
 õÖÅÌØ ÎÉÞÔÏ ÔÅÂÅ × ÔÏ ×ÒÅÍÑ ÎÅ ÛÅÐÎÕÌÏ: /
diff --git a/t/corpus/koi8r.txt b/t/corpus/koi8r.txt
index c15d742..3ad4274 100644
--- a/t/corpus/koi8r.txt
+++ b/t/corpus/koi8r.txt
@@ -13,12 +13,12 @@
 çÄÅ ÓÅÒÄÃÁ Ú×ÕÞÎÙÊ ÐÙÌ ÓÉÑÎØÅ ÌØÅÔ ËÒÕÇÏÍ /
 é ÓÔÒÁÓÔÉ ÒÏËÏ×ÏÊ ×ÚÄÙÍÁÀÔÓÑ ÐÏÔÏËÉ,- /
       îÅ ×ÓÐÏÍÎÉÌÁ ÌØ Ï ÞÅÍ?
-      
+
 ñ ×ÅÒÉÔØ ÎÅ ÈÏÞÕ! ëÏÇÄÁ × ÓÔÅÐÉ, ËÁË ÄÉ×Ï, /
 ÷ ÐÏÌÎÏÞÎÏÊ ÔÅÍÎÏÔÅ ÂÅÚ×ÒÅÍÅÎÎÏ ÇÏÒÑ, /
 ÷ÄÁÌÉ ÐÅÒÅÄ ÔÏÂÏÊ ÐÒÏÚÒÁÞÎÏ É ËÒÁÓÉ×Ï /
       ÷ÓÔÁ×ÁÌÁ ×ÄÒÕÇÚÁÒÑ.
-      
+
 é × ÜÔÕ ËÒÁÓÏÔÕ ÎÅ×ÏÌØÎÏ ×ÚÏÒ ÔÑÎÕÌÏ, /
 ÷ ÔÏÔ ×ÅÌÉÞÁ×ÙÊ ÂÌÅÓË ÚÁ ÔÅÍÎÙÊ ×ÅÓØ ÐÒÅÄÅÌ,- /
 õÖÅÌØ ÎÉÞÔÏ ÔÅÂÅ × ÔÏ ×ÒÅÍÑ ÎÅ ÛÅÐÎÕÌÏ: /
diff --git a/t/corpus/whitespace.txt b/t/corpus/whitespace.txt
new file mode 100644
index 0000000..5ef14c9
--- /dev/null
+++ b/t/corpus/whitespace.txt
@@ -0,0 +1,9 @@
+=pod
+
+=head1 FOO
+
+Some reasonably sensible pod.
+   
+Shockingly, the previous line had whitespace.
+
+=cut
diff --git a/t/corpus/whitespace.xml b/t/corpus/whitespace.xml
new file mode 100644
index 0000000..d33579c
--- /dev/null
+++ b/t/corpus/whitespace.xml
@@ -0,0 +1,29 @@
+<Document start_line="1">
+  <head1 start_line="3">
+    FOO
+  </head1>
+  <Para start_line="5">
+    Some reasonably sensible pod.
+  </Para>
+  <Para start_line="7">
+    Shockingly, the previous line had whitespace.
+  </Para>
+  <head1 errata="1" start_line="-321">
+    POD ERRORS
+  </head1>
+  <Para errata="1" start_line="-321">
+    Hey! 
+    <B>
+      The above document had some coding errors, which are explained
+      below:
+    </B>
+  </Para>
+  <over-text errata="1" indent="4" start_line="-321">
+    <item-text start_line="-321">
+      Around line 6:
+    </item-text>
+    <Para start_line="-321">
+      line containing nothing but whitespace
+    </Para>
+  </over-text>
+</Document>
diff --git a/t/html01.t b/t/html01.t
index 5ad848e..a0f919b 100644
--- a/t/html01.t
+++ b/t/html01.t
@@ -25,9 +25,9 @@ sub x ($;&) {
 ok( x(
 q{
 =pod
- 
+
 This is a paragraph
- 
+
 =cut
 }),
   qq{\n<p>This is a paragraph</p>\n},
-- 
1.7.3.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.