Add handle_code() method to Pod::Simple::XHTML

[email protected] (Gisle Aas)
Newsgroups perl.pod-people
Message-ID <[email protected]>
For ActivePerl we plug in a syntax highlighter for the code snippets in the generated HTML documentation.  In order to support this for perl-5.16 I ended up patching Pod::Simple::XHTML like this:

   https://github.com/gisle/pod-simple/commit/9cafd6c5dd1aa753ba0dc698324b1fe6ef05274d

We will then subclass Pod::Simple::XHTML to invoke our syntax highlighter in an overridden handle_code method.

For this to work without much hassle I also found that I needed to add code to join subsequent text segments so that they were all processed by a single _handle_text invocation:

   https://github.com/gisle/pod-simple/commit/b6bd1521d06246b6c314e149287a590a1ed21da3

Does this look like a sane way to approach this?

--Gisle
0001-Join-subsequent-text-segments-before-passing-them-to.patch (application/octet-stream, 41 KB)
From b6bd1521d06246b6c314e149287a590a1ed21da3 Mon Sep 17 00:00:00 2001
From: Gisle Aas <[email protected]>
Date: Sat, 21 Apr 2012 17:38:34 +0200
Subject: [PATCH 1/2] Join subsequent text segments before passing them to
 _handle_text

This makes it much easier to process text using custom handlers.
---
 lib/Pod/Simple/BlackBox.pm    |    6 ++-
 t/corpus/cp1256.xml           |    9 +--
 t/corpus/fet_dup.xml          |   39 +++++----------
 t/corpus/iso6.xml             |    9 +--
 t/corpus/koi8r.xml            |   45 ++++++-----------
 t/corpus/laozi38.xml          |   33 ++++--------
 t/corpus/laozi38b.xml         |   33 ++++--------
 t/corpus/laozi38p.xml         |   33 ++++--------
 t/corpus/lat1fr.xml           |   28 +++-------
 t/corpus/lat1frim.xml         |   28 +++-------
 t/corpus/pasternak_cp1251.xml |  108 ++++++++++++----------------------------
 t/corpus/polish_utf8.xml      |   66 ++++++++-----------------
 t/corpus/thai_iso11.xml       |   48 ++++++------------
 t/x_nixer.t                   |   11 +---
 14 files changed, 162 insertions(+), 334 deletions(-)

diff --git a/lib/Pod/Simple/BlackBox.pm b/lib/Pod/Simple/BlackBox.pm
index b6e8f7a..a1db54e 100644
--- a/lib/Pod/Simple/BlackBox.pm
+++ b/lib/Pod/Simple/BlackBox.pm
@@ -1459,10 +1459,12 @@ sub _traverse_treelet_bit {  # for use only by the routine above
   my $scratch;
   $self->_handle_element_start(($scratch=$name), shift @_);
   
-  foreach my $x (@_) {
-    if(ref($x)) {
+  while (@_) {
+    my $x = shift;
+    if (ref($x)) {
       &_traverse_treelet_bit($self, @$x);
     } else {
+      $x .= shift while @_ && !ref($_[0]);
       $self->_handle_text($x);
     }
   }
diff --git a/t/corpus/cp1256.xml b/t/corpus/cp1256.xml
index deacfd6..7f3021b 100644
--- a/t/corpus/cp1256.xml
+++ b/t/corpus/cp1256.xml
@@ -73,20 +73,17 @@
     &#1602;&#1575;&#1604; &#1585;&#1587;&#1608;&#1604; &#1575;&#1604;&#1604;&#1607;
     &#1589;&#1604;&#1609; &#1575;&#1604;&#1604;&#1607; &#1593;&#1604;&#1610;&#1607;
     &#1608;&#1587;&#1604;&#1605;:
-
-      &#1575;&#1585;&#1576;&#1593; &#1601;&#1585;&#1590;&#1607;&#1606;
+  &#1575;&#1585;&#1576;&#1593; &#1601;&#1585;&#1590;&#1607;&#1606;
     &#1575;&#1604;&#1604;&#1607; &#1593;&#1586; &#1608;&#1580;&#1604;
     &#1601;&#1610; &#1575;&#1604;&#1575;&#1587;&#1604;&#1575;&#1605;
     &#1601;&#1605;&#1606; &#1580;&#1575;&#1569; &#1576;&#1579;&#1604;&#1575;&#1579;
     &#1604;&#1605; &#1610;&#1594;&#1606;&#1610;&#1606; &#1593;&#1606;&#1607;
-
-      &#1588;&#1610;&#1574;&#1575; &#1581;&#1578;&#1609; &#1610;&#1571;&#1578;&#1610;
+  &#1588;&#1610;&#1574;&#1575; &#1581;&#1578;&#1609; &#1610;&#1571;&#1578;&#1610;
     &#1576;&#1607;&#1606; &#1580;&#1605;&#1610;&#1593;&#1575;
     &#1575;&#1604;&#1589;&#1604;&#1575;&#1577; &#1608;&#1575;&#1604;&#1586;&#1603;&#1575;&#1577;
     &#1608;&#1589;&#1610;&#1575;&#1605; &#1585;&#1605;&#1590;&#1575;&#1606;
     &#1608;&#1581;&#1580;
-
-      &#1575;&#1604;&#1576;&#1610;&#1578;. &#1585;&#1608;&#1575;&#1607;
+  &#1575;&#1604;&#1576;&#1610;&#1578;. &#1585;&#1608;&#1575;&#1607;
     &#1575;&#1581;&#1605;&#1583; &#1608;&#1575;&#1604;&#1591;&#1576;&#1585;&#1575;&#1606;&#1610;
     &#1601;&#1610; &#1575;&#1604;&#1603;&#1576;&#1610;&#1585;
     &#1608;&#1601;&#1610; &#1575;&#1587;&#1606;&#1575;&#1583;&#1607;
diff --git a/t/corpus/fet_dup.xml b/t/corpus/fet_dup.xml
index c33277d..92addce 100644
--- a/t/corpus/fet_dup.xml
+++ b/t/corpus/fet_dup.xml
@@ -63,56 +63,43 @@
       &#1050;&#1086;&#1075;&#1076;&#1072; &#1095;&#1080;&#1090;&#1072;&#1083;&#1072;
     &#1090;&#1099; &#1084;&#1091;&#1095;&#1080;&#1090;&#1077;&#1083;&#1100;&#1085;&#1099;&#1077;
     &#1089;&#1090;&#1088;&#1086;&#1082;&#1080;,
-
-      &#1043;&#1076;&#1077; &#1089;&#1077;&#1088;&#1076;&#1094;&#1072;
+  &#1043;&#1076;&#1077; &#1089;&#1077;&#1088;&#1076;&#1094;&#1072;
     &#1079;&#1074;&#1091;&#1095;&#1085;&#1099;&#1081; &#1087;&#1099;&#1083;
     &#1089;&#1080;&#1103;&#1085;&#1100;&#1077; &#1083;&#1100;&#1077;&#1090;
     &#1082;&#1088;&#1091;&#1075;&#1086;&#1084;
-
-      &#1048; &#1089;&#1090;&#1088;&#1072;&#1089;&#1090;&#1080;
+  &#1048; &#1089;&#1090;&#1088;&#1072;&#1089;&#1090;&#1080;
     &#1088;&#1086;&#1082;&#1086;&#1074;&#1086;&#1081; &#1074;&#1079;&#1076;&#1099;&#1084;&#1072;&#1102;&#1090;&#1089;&#1103;
     &#1087;&#1086;&#1090;&#1086;&#1082;&#1080;,-
-
-            &#1053;&#1077; &#1074;&#1089;&#1087;&#1086;&#1084;&#1085;&#1080;&#1083;&#1072;
+        &#1053;&#1077; &#1074;&#1089;&#1087;&#1086;&#1084;&#1085;&#1080;&#1083;&#1072;
     &#1083;&#1100; &#1086; &#1095;&#1077;&#1084;?
-
-            
-
-      &#1071; &#1074;&#1077;&#1088;&#1080;&#1090;&#1100; &#1085;&#1077;
+        
+  &#1071; &#1074;&#1077;&#1088;&#1080;&#1090;&#1100; &#1085;&#1077;
     &#1093;&#1086;&#1095;&#1091;! &#1050;&#1086;&#1075;&#1076;&#1072;
     &#1074; &#1089;&#1090;&#1077;&#1087;&#1080;, &#1082;&#1072;&#1082;
     &#1076;&#1080;&#1074;&#1086;,
-
-      &#1042; &#1087;&#1086;&#1083;&#1085;&#1086;&#1095;&#1085;&#1086;&#1081;
+  &#1042; &#1087;&#1086;&#1083;&#1085;&#1086;&#1095;&#1085;&#1086;&#1081;
     &#1090;&#1077;&#1084;&#1085;&#1086;&#1090;&#1077; &#1073;&#1077;&#1079;&#1074;&#1088;&#1077;&#1084;&#1077;&#1085;&#1085;&#1086;
     &#1075;&#1086;&#1088;&#1103;,
-
-      &#1042;&#1076;&#1072;&#1083;&#1080; &#1087;&#1077;&#1088;&#1077;&#1076;
+  &#1042;&#1076;&#1072;&#1083;&#1080; &#1087;&#1077;&#1088;&#1077;&#1076;
     &#1090;&#1086;&#1073;&#1086;&#1081; &#1087;&#1088;&#1086;&#1079;&#1088;&#1072;&#1095;&#1085;&#1086;
     &#1080; &#1082;&#1088;&#1072;&#1089;&#1080;&#1074;&#1086;
-
-            &#1042;&#1089;&#1090;&#1072;&#1074;&#1072;&#1083;&#1072;
+        &#1042;&#1089;&#1090;&#1072;&#1074;&#1072;&#1083;&#1072;
     &#1074;&#1076;&#1088;&#1091;&#1075;&#1079;&#1072;&#1088;&#1103;.
   </VerbatimFormatted>
   <VerbatimFormatted start_line="46" xml:space="preserve">
       &#1048; &#1074; &#1101;&#1090;&#1091; &#1082;&#1088;&#1072;&#1089;&#1086;&#1090;&#1091;
     &#1085;&#1077;&#1074;&#1086;&#1083;&#1100;&#1085;&#1086;
     &#1074;&#1079;&#1086;&#1088; &#1090;&#1103;&#1085;&#1091;&#1083;&#1086;,
-
-      &#1042; &#1090;&#1086;&#1090; &#1074;&#1077;&#1083;&#1080;&#1095;&#1072;&#1074;&#1099;&#1081;
+  &#1042; &#1090;&#1086;&#1090; &#1074;&#1077;&#1083;&#1080;&#1095;&#1072;&#1074;&#1099;&#1081;
     &#1073;&#1083;&#1077;&#1089;&#1082; &#1079;&#1072; &#1090;&#1077;&#1084;&#1085;&#1099;&#1081;
     &#1074;&#1077;&#1089;&#1100; &#1087;&#1088;&#1077;&#1076;&#1077;&#1083;,-
-
-      &#1059;&#1078;&#1077;&#1083;&#1100; &#1085;&#1080;&#1095;&#1090;&#1086;
+  &#1059;&#1078;&#1077;&#1083;&#1100; &#1085;&#1080;&#1095;&#1090;&#1086;
     &#1090;&#1077;&#1073;&#1077; &#1074; &#1090;&#1086; &#1074;&#1088;&#1077;&#1084;&#1103;
     &#1085;&#1077; &#1096;&#1077;&#1087;&#1085;&#1091;&#1083;&#1086;:
-
-           &#1058;&#1072;&#1084; &#1095;&#1077;&#1083;&#1086;&#1074;&#1077;&#1082;
+       &#1058;&#1072;&#1084; &#1095;&#1077;&#1083;&#1086;&#1074;&#1077;&#1082;
     &#1089;&#1075;&#1086;&#1088;&#1077;&#1083;!
-
-      
-
-        15 &#1092;&#1077;&#1074;&#1088;&#1072;&#1083;&#1103;
+  
+    15 &#1092;&#1077;&#1074;&#1088;&#1072;&#1083;&#1103;
     1887
   </VerbatimFormatted>
   <Para start_line="53">
diff --git a/t/corpus/iso6.xml b/t/corpus/iso6.xml
index b597324..b0d6ec4 100644
--- a/t/corpus/iso6.xml
+++ b/t/corpus/iso6.xml
@@ -74,20 +74,17 @@
     &#1602;&#1575;&#1604; &#1585;&#1587;&#1608;&#1604; &#1575;&#1604;&#1604;&#1607;
     &#1589;&#1604;&#1609; &#1575;&#1604;&#1604;&#1607; &#1593;&#1604;&#1610;&#1607;
     &#1608;&#1587;&#1604;&#1605;:
-
-      &#1575;&#1585;&#1576;&#1593; &#1601;&#1585;&#1590;&#1607;&#1606;
+  &#1575;&#1585;&#1576;&#1593; &#1601;&#1585;&#1590;&#1607;&#1606;
     &#1575;&#1604;&#1604;&#1607; &#1593;&#1586; &#1608;&#1580;&#1604;
     &#1601;&#1610; &#1575;&#1604;&#1575;&#1587;&#1604;&#1575;&#1605;
     &#1601;&#1605;&#1606; &#1580;&#1575;&#1569; &#1576;&#1579;&#1604;&#1575;&#1579;
     &#1604;&#1605; &#1610;&#1594;&#1606;&#1610;&#1606; &#1593;&#1606;&#1607;
-
-      &#1588;&#1610;&#1574;&#1575; &#1581;&#1578;&#1609; &#1610;&#1571;&#1578;&#1610;
+  &#1588;&#1610;&#1574;&#1575; &#1581;&#1578;&#1609; &#1610;&#1571;&#1578;&#1610;
     &#1576;&#1607;&#1606; &#1580;&#1605;&#1610;&#1593;&#1575;
     &#1575;&#1604;&#1589;&#1604;&#1575;&#1577; &#1608;&#1575;&#1604;&#1586;&#1603;&#1575;&#1577;
     &#1608;&#1589;&#1610;&#1575;&#1605; &#1585;&#1605;&#1590;&#1575;&#1606;
     &#1608;&#1581;&#1580;
-
-      &#1575;&#1604;&#1576;&#1610;&#1578;. &#1585;&#1608;&#1575;&#1607;
+  &#1575;&#1604;&#1576;&#1610;&#1578;. &#1585;&#1608;&#1575;&#1607;
     &#1575;&#1581;&#1605;&#1583; &#1608;&#1575;&#1604;&#1591;&#1576;&#1585;&#1575;&#1606;&#1610;
     &#1601;&#1610; &#1575;&#1604;&#1603;&#1576;&#1610;&#1585;
     &#1608;&#1601;&#1610; &#1575;&#1587;&#1606;&#1575;&#1583;&#1607;
diff --git a/t/corpus/koi8r.xml b/t/corpus/koi8r.xml
index 94331d7..8febf8d 100644
--- a/t/corpus/koi8r.xml
+++ b/t/corpus/koi8r.xml
@@ -63,57 +63,42 @@
       &#1050;&#1086;&#1075;&#1076;&#1072; &#1095;&#1080;&#1090;&#1072;&#1083;&#1072;
     &#1090;&#1099; &#1084;&#1091;&#1095;&#1080;&#1090;&#1077;&#1083;&#1100;&#1085;&#1099;&#1077;
     &#1089;&#1090;&#1088;&#1086;&#1082;&#1080;,
-
-      &#1043;&#1076;&#1077; &#1089;&#1077;&#1088;&#1076;&#1094;&#1072;
+  &#1043;&#1076;&#1077; &#1089;&#1077;&#1088;&#1076;&#1094;&#1072;
     &#1079;&#1074;&#1091;&#1095;&#1085;&#1099;&#1081; &#1087;&#1099;&#1083;
     &#1089;&#1080;&#1103;&#1085;&#1100;&#1077; &#1083;&#1100;&#1077;&#1090;
     &#1082;&#1088;&#1091;&#1075;&#1086;&#1084;
-
-      &#1048; &#1089;&#1090;&#1088;&#1072;&#1089;&#1090;&#1080;
+  &#1048; &#1089;&#1090;&#1088;&#1072;&#1089;&#1090;&#1080;
     &#1088;&#1086;&#1082;&#1086;&#1074;&#1086;&#1081; &#1074;&#1079;&#1076;&#1099;&#1084;&#1072;&#1102;&#1090;&#1089;&#1103;
     &#1087;&#1086;&#1090;&#1086;&#1082;&#1080;,-
-
-            &#1053;&#1077; &#1074;&#1089;&#1087;&#1086;&#1084;&#1085;&#1080;&#1083;&#1072;
+        &#1053;&#1077; &#1074;&#1089;&#1087;&#1086;&#1084;&#1085;&#1080;&#1083;&#1072;
     &#1083;&#1100; &#1086; &#1095;&#1077;&#1084;?
-
-            
-
-      &#1071; &#1074;&#1077;&#1088;&#1080;&#1090;&#1100; &#1085;&#1077;
+        
+  &#1071; &#1074;&#1077;&#1088;&#1080;&#1090;&#1100; &#1085;&#1077;
     &#1093;&#1086;&#1095;&#1091;! &#1050;&#1086;&#1075;&#1076;&#1072;
     &#1074; &#1089;&#1090;&#1077;&#1087;&#1080;, &#1082;&#1072;&#1082;
     &#1076;&#1080;&#1074;&#1086;,
-
-      &#1042; &#1087;&#1086;&#1083;&#1085;&#1086;&#1095;&#1085;&#1086;&#1081;
+  &#1042; &#1087;&#1086;&#1083;&#1085;&#1086;&#1095;&#1085;&#1086;&#1081;
     &#1090;&#1077;&#1084;&#1085;&#1086;&#1090;&#1077; &#1073;&#1077;&#1079;&#1074;&#1088;&#1077;&#1084;&#1077;&#1085;&#1085;&#1086;
     &#1075;&#1086;&#1088;&#1103;,
-
-      &#1042;&#1076;&#1072;&#1083;&#1080; &#1087;&#1077;&#1088;&#1077;&#1076;
+  &#1042;&#1076;&#1072;&#1083;&#1080; &#1087;&#1077;&#1088;&#1077;&#1076;
     &#1090;&#1086;&#1073;&#1086;&#1081; &#1087;&#1088;&#1086;&#1079;&#1088;&#1072;&#1095;&#1085;&#1086;
     &#1080; &#1082;&#1088;&#1072;&#1089;&#1080;&#1074;&#1086;
-
-            &#1042;&#1089;&#1090;&#1072;&#1074;&#1072;&#1083;&#1072;
+        &#1042;&#1089;&#1090;&#1072;&#1074;&#1072;&#1083;&#1072;
     &#1074;&#1076;&#1088;&#1091;&#1075;&#1079;&#1072;&#1088;&#1103;.
-
-            
-
-      &#1048; &#1074; &#1101;&#1090;&#1091; &#1082;&#1088;&#1072;&#1089;&#1086;&#1090;&#1091;
+        
+  &#1048; &#1074; &#1101;&#1090;&#1091; &#1082;&#1088;&#1072;&#1089;&#1086;&#1090;&#1091;
     &#1085;&#1077;&#1074;&#1086;&#1083;&#1100;&#1085;&#1086;
     &#1074;&#1079;&#1086;&#1088; &#1090;&#1103;&#1085;&#1091;&#1083;&#1086;,
-
-      &#1042; &#1090;&#1086;&#1090; &#1074;&#1077;&#1083;&#1080;&#1095;&#1072;&#1074;&#1099;&#1081;
+  &#1042; &#1090;&#1086;&#1090; &#1074;&#1077;&#1083;&#1080;&#1095;&#1072;&#1074;&#1099;&#1081;
     &#1073;&#1083;&#1077;&#1089;&#1082; &#1079;&#1072; &#1090;&#1077;&#1084;&#1085;&#1099;&#1081;
     &#1074;&#1077;&#1089;&#1100; &#1087;&#1088;&#1077;&#1076;&#1077;&#1083;,-
-
-      &#1059;&#1078;&#1077;&#1083;&#1100; &#1085;&#1080;&#1095;&#1090;&#1086;
+  &#1059;&#1078;&#1077;&#1083;&#1100; &#1085;&#1080;&#1095;&#1090;&#1086;
     &#1090;&#1077;&#1073;&#1077; &#1074; &#1090;&#1086; &#1074;&#1088;&#1077;&#1084;&#1103;
     &#1085;&#1077; &#1096;&#1077;&#1087;&#1085;&#1091;&#1083;&#1086;:
-
-           &#1058;&#1072;&#1084; &#1095;&#1077;&#1083;&#1086;&#1074;&#1077;&#1082;
+       &#1058;&#1072;&#1084; &#1095;&#1077;&#1083;&#1086;&#1074;&#1077;&#1082;
     &#1089;&#1075;&#1086;&#1088;&#1077;&#1083;!
-
-      
-
-        15 &#1092;&#1077;&#1074;&#1088;&#1072;&#1083;&#1103;
+  
+    15 &#1092;&#1077;&#1074;&#1088;&#1072;&#1083;&#1103;
     1887
   </VerbatimFormatted>
   <Para start_line="48">
diff --git a/t/corpus/laozi38.xml b/t/corpus/laozi38.xml
index 5ff7251..e0d5f78 100644
--- a/t/corpus/laozi38.xml
+++ b/t/corpus/laozi38.xml
@@ -23,28 +23,17 @@
   </Para>
   <VerbatimFormatted start_line="20" xml:space="preserve">
       &#19978;&#24503;&#19981;&#24503;&#65292;&#26159;&#20197;&#26377;&#24503;&#65108;
-
-      &#19979;&#24503;&#19981;&#22833;&#24503;&#65292;&#26159;&#20197;&#28961;&#24503;&#12290;
-
-      &#19978;&#24503;&#28961;&#28858;&#32780;&#28961;&#20197;&#28858;&#65108;
-
-      &#19979;&#24503;&#28961;&#28858;&#32780;&#26377;&#20197;&#28858;&#12290;
-
-      &#19978;&#20161;&#28858;&#20043;&#32780;&#28961;&#20197;&#28858;&#65108;
-
-      &#19978;&#32681;&#28858;&#20043;&#32780;&#26377;&#20197;&#28858;&#12290;
-
-      &#19978;&#31150;&#28858;&#20043;&#32780;&#33707;&#20043;&#25033;&#65292;&#21063;&#25880;&#33218;&#32780;&#25172;&#20043;&#12290;
-
-      
-
-      &#25925;&#22833;&#36947;&#32780;&#21518;&#24503;&#65292;&#22833;&#24503;&#32780;&#21518;&#20161;&#65292;&#22833;&#20161;&#32780;&#21518;&#32681;&#65292;&#22833;&#32681;&#32780;&#21518;&#31150;&#12290;&#22827;&#31150;&#32773;&#65292;&#24544;&#20449;&#20043;&#34180;&#65292;&#32780;&#20098;&#20043;&#39318;&#12290;
-
-      &#21069;&#35672;&#32773;&#65292;&#36947;&#20043;&#33775;&#65292;&#32780;&#24858;&#20043;&#22987;&#12290;
-
-      &#26159;&#20197;&#22823;&#19976;&#22827;&#23621;&#20854;&#21402;&#65292;&#19981;&#23621;&#20854;&#34180;&#65108;&#23621;&#20854;&#23526;&#65292;&#19981;&#23621;&#20854;&#33775;&#12290;
-
-      &#25925;&#21435;&#24444;&#21462;&#27492;&#12290;
+  &#19979;&#24503;&#19981;&#22833;&#24503;&#65292;&#26159;&#20197;&#28961;&#24503;&#12290;
+  &#19978;&#24503;&#28961;&#28858;&#32780;&#28961;&#20197;&#28858;&#65108;
+  &#19979;&#24503;&#28961;&#28858;&#32780;&#26377;&#20197;&#28858;&#12290;
+  &#19978;&#20161;&#28858;&#20043;&#32780;&#28961;&#20197;&#28858;&#65108;
+  &#19978;&#32681;&#28858;&#20043;&#32780;&#26377;&#20197;&#28858;&#12290;
+  &#19978;&#31150;&#28858;&#20043;&#32780;&#33707;&#20043;&#25033;&#65292;&#21063;&#25880;&#33218;&#32780;&#25172;&#20043;&#12290;
+  
+  &#25925;&#22833;&#36947;&#32780;&#21518;&#24503;&#65292;&#22833;&#24503;&#32780;&#21518;&#20161;&#65292;&#22833;&#20161;&#32780;&#21518;&#32681;&#65292;&#22833;&#32681;&#32780;&#21518;&#31150;&#12290;&#22827;&#31150;&#32773;&#65292;&#24544;&#20449;&#20043;&#34180;&#65292;&#32780;&#20098;&#20043;&#39318;&#12290;
+  &#21069;&#35672;&#32773;&#65292;&#36947;&#20043;&#33775;&#65292;&#32780;&#24858;&#20043;&#22987;&#12290;
+  &#26159;&#20197;&#22823;&#19976;&#22827;&#23621;&#20854;&#21402;&#65292;&#19981;&#23621;&#20854;&#34180;&#65108;&#23621;&#20854;&#23526;&#65292;&#19981;&#23621;&#20854;&#33775;&#12290;
+  &#25925;&#21435;&#24444;&#21462;&#27492;&#12290;
   </VerbatimFormatted>
   <Para start_line="33">
     [end]
diff --git a/t/corpus/laozi38b.xml b/t/corpus/laozi38b.xml
index 5ff7251..e0d5f78 100644
--- a/t/corpus/laozi38b.xml
+++ b/t/corpus/laozi38b.xml
@@ -23,28 +23,17 @@
   </Para>
   <VerbatimFormatted start_line="20" xml:space="preserve">
       &#19978;&#24503;&#19981;&#24503;&#65292;&#26159;&#20197;&#26377;&#24503;&#65108;
-
-      &#19979;&#24503;&#19981;&#22833;&#24503;&#65292;&#26159;&#20197;&#28961;&#24503;&#12290;
-
-      &#19978;&#24503;&#28961;&#28858;&#32780;&#28961;&#20197;&#28858;&#65108;
-
-      &#19979;&#24503;&#28961;&#28858;&#32780;&#26377;&#20197;&#28858;&#12290;
-
-      &#19978;&#20161;&#28858;&#20043;&#32780;&#28961;&#20197;&#28858;&#65108;
-
-      &#19978;&#32681;&#28858;&#20043;&#32780;&#26377;&#20197;&#28858;&#12290;
-
-      &#19978;&#31150;&#28858;&#20043;&#32780;&#33707;&#20043;&#25033;&#65292;&#21063;&#25880;&#33218;&#32780;&#25172;&#20043;&#12290;
-
-      
-
-      &#25925;&#22833;&#36947;&#32780;&#21518;&#24503;&#65292;&#22833;&#24503;&#32780;&#21518;&#20161;&#65292;&#22833;&#20161;&#32780;&#21518;&#32681;&#65292;&#22833;&#32681;&#32780;&#21518;&#31150;&#12290;&#22827;&#31150;&#32773;&#65292;&#24544;&#20449;&#20043;&#34180;&#65292;&#32780;&#20098;&#20043;&#39318;&#12290;
-
-      &#21069;&#35672;&#32773;&#65292;&#36947;&#20043;&#33775;&#65292;&#32780;&#24858;&#20043;&#22987;&#12290;
-
-      &#26159;&#20197;&#22823;&#19976;&#22827;&#23621;&#20854;&#21402;&#65292;&#19981;&#23621;&#20854;&#34180;&#65108;&#23621;&#20854;&#23526;&#65292;&#19981;&#23621;&#20854;&#33775;&#12290;
-
-      &#25925;&#21435;&#24444;&#21462;&#27492;&#12290;
+  &#19979;&#24503;&#19981;&#22833;&#24503;&#65292;&#26159;&#20197;&#28961;&#24503;&#12290;
+  &#19978;&#24503;&#28961;&#28858;&#32780;&#28961;&#20197;&#28858;&#65108;
+  &#19979;&#24503;&#28961;&#28858;&#32780;&#26377;&#20197;&#28858;&#12290;
+  &#19978;&#20161;&#28858;&#20043;&#32780;&#28961;&#20197;&#28858;&#65108;
+  &#19978;&#32681;&#28858;&#20043;&#32780;&#26377;&#20197;&#28858;&#12290;
+  &#19978;&#31150;&#28858;&#20043;&#32780;&#33707;&#20043;&#25033;&#65292;&#21063;&#25880;&#33218;&#32780;&#25172;&#20043;&#12290;
+  
+  &#25925;&#22833;&#36947;&#32780;&#21518;&#24503;&#65292;&#22833;&#24503;&#32780;&#21518;&#20161;&#65292;&#22833;&#20161;&#32780;&#21518;&#32681;&#65292;&#22833;&#32681;&#32780;&#21518;&#31150;&#12290;&#22827;&#31150;&#32773;&#65292;&#24544;&#20449;&#20043;&#34180;&#65292;&#32780;&#20098;&#20043;&#39318;&#12290;
+  &#21069;&#35672;&#32773;&#65292;&#36947;&#20043;&#33775;&#65292;&#32780;&#24858;&#20043;&#22987;&#12290;
+  &#26159;&#20197;&#22823;&#19976;&#22827;&#23621;&#20854;&#21402;&#65292;&#19981;&#23621;&#20854;&#34180;&#65108;&#23621;&#20854;&#23526;&#65292;&#19981;&#23621;&#20854;&#33775;&#12290;
+  &#25925;&#21435;&#24444;&#21462;&#27492;&#12290;
   </VerbatimFormatted>
   <Para start_line="33">
     [end]
diff --git a/t/corpus/laozi38p.xml b/t/corpus/laozi38p.xml
index bae00f2..122c5fc 100644
--- a/t/corpus/laozi38p.xml
+++ b/t/corpus/laozi38p.xml
@@ -40,28 +40,17 @@
   </Para>
   <VerbatimFormatted start_line="30" xml:space="preserve">
       &#19978;&#24503;&#19981;&#24503;&#65292;&#26159;&#20197;&#26377;&#24503;&#65108;
-
-       &#19979;&#24503;&#19981;&#22833;&#24503;&#65292;&#26159;&#20197;&#28961;&#24503;&#12290;
-
-      &#19978;&#24503;&#28961;&#28858;&#32780;&#28961;&#20197;&#28858;&#65108;
-
-       &#19979;&#24503;&#28961;&#28858;&#32780;&#26377;&#20197;&#28858;&#12290;
-
-      &#19978;&#20161;&#28858;&#20043;&#32780;&#28961;&#20197;&#28858;&#65108;
-
-       &#19978;&#32681;&#28858;&#20043;&#32780;&#26377;&#20197;&#28858;&#12290;
-
-      &#19978;&#31150;&#28858;&#20043;&#32780;&#33707;&#20043;&#25033;&#65292;&#21063;&#25880;&#33218;&#32780;&#25172;&#20043;&#12290;
-
-      
-
-      &#25925;&#22833;&#36947;&#32780;&#21518;&#24503;&#65292;&#22833;&#24503;&#32780;&#21518;&#20161;&#65292;&#22833;&#20161;&#32780;&#21518;&#32681;&#65292;&#22833;&#32681;&#32780;&#21518;&#31150;&#12290;&#22827;&#31150;&#32773;&#65292;&#24544;&#20449;&#20043;&#34180;&#65292;&#32780;&#20098;&#20043;&#39318;&#12290;
-
-      &#21069;&#35672;&#32773;&#65292;&#36947;&#20043;&#33775;&#65292;&#32780;&#24858;&#20043;&#22987;&#12290;
-
-      &#26159;&#20197;&#22823;&#19976;&#22827;&#23621;&#20854;&#21402;&#65292;&#19981;&#23621;&#20854;&#34180;&#65108;&#23621;&#20854;&#23526;&#65292;&#19981;&#23621;&#20854;&#33775;&#12290;
-
-      &#25925;&#21435;&#24444;&#21462;&#27492;&#12290;
+   &#19979;&#24503;&#19981;&#22833;&#24503;&#65292;&#26159;&#20197;&#28961;&#24503;&#12290;
+  &#19978;&#24503;&#28961;&#28858;&#32780;&#28961;&#20197;&#28858;&#65108;
+   &#19979;&#24503;&#28961;&#28858;&#32780;&#26377;&#20197;&#28858;&#12290;
+  &#19978;&#20161;&#28858;&#20043;&#32780;&#28961;&#20197;&#28858;&#65108;
+   &#19978;&#32681;&#28858;&#20043;&#32780;&#26377;&#20197;&#28858;&#12290;
+  &#19978;&#31150;&#28858;&#20043;&#32780;&#33707;&#20043;&#25033;&#65292;&#21063;&#25880;&#33218;&#32780;&#25172;&#20043;&#12290;
+  
+  &#25925;&#22833;&#36947;&#32780;&#21518;&#24503;&#65292;&#22833;&#24503;&#32780;&#21518;&#20161;&#65292;&#22833;&#20161;&#32780;&#21518;&#32681;&#65292;&#22833;&#32681;&#32780;&#21518;&#31150;&#12290;&#22827;&#31150;&#32773;&#65292;&#24544;&#20449;&#20043;&#34180;&#65292;&#32780;&#20098;&#20043;&#39318;&#12290;
+  &#21069;&#35672;&#32773;&#65292;&#36947;&#20043;&#33775;&#65292;&#32780;&#24858;&#20043;&#22987;&#12290;
+  &#26159;&#20197;&#22823;&#19976;&#22827;&#23621;&#20854;&#21402;&#65292;&#19981;&#23621;&#20854;&#34180;&#65108;&#23621;&#20854;&#23526;&#65292;&#19981;&#23621;&#20854;&#33775;&#12290;
+  &#25925;&#21435;&#24444;&#21462;&#27492;&#12290;
   </VerbatimFormatted>
   <Para start_line="43">
     [end]
diff --git a/t/corpus/lat1fr.xml b/t/corpus/lat1fr.xml
index 017ae6a..4191c44 100644
--- a/t/corpus/lat1fr.xml
+++ b/t/corpus/lat1fr.xml
@@ -23,10 +23,8 @@
     celui-ci examinait avidement comme un objet rare et inconnu.
     Or, ce joujou, que le petit souillon aga&#231;ait, agitait
     et secouait dans une bo&#238;te grill&#233;e, c&#39;&#233;tait
-    un rat vivant
-    &#160;
-    ! Les parents, par &#233;conomie sans doute, avaient tir&#233;
-    le joujou de la vie elle-m&#234;me.
+    un rat vivant&#160;! Les parents, par &#233;conomie sans
+    doute, avaient tir&#233; le joujou de la vie elle-m&#234;me.
   </Para>
   <Para start_line="20">
     Et les deux enfants se riaient l&#39;un &#224; l&#39;autre
@@ -42,27 +40,19 @@
   <VerbatimFormatted start_line="25" xml:space="preserve">
      A travers ces barreaux symboliques s&#233;parant deux mondes,
     la grande route
-
-     et le ch&#226;teau, l&#39;enfant pauvre montrait &#224;
+ et le ch&#226;teau, l&#39;enfant pauvre montrait &#224;
     l&#39;enfant riche son propre
-
-     joujou, que celui-ci examinait avidement comme un objet
+ joujou, que celui-ci examinait avidement comme un objet
     rare et inconnu.
-
-     Or, ce joujou, que le petit souillon aga&#231;ait, agitait
+ Or, ce joujou, que le petit souillon aga&#231;ait, agitait
     et secouait dans
-
-     une bo&#238;te grill&#233;e, c&#39;&#233;tait un rat vivant&#160;!
+ une bo&#238;te grill&#233;e, c&#39;&#233;tait un rat vivant&#160;!
     Les parents, par &#233;conomie
+ sans doute, avaient tir&#233; le joujou de la vie elle-m&#234;me. 
 
-     sans doute, avaient tir&#233; le joujou de la vie elle-m&#234;me. 
-
-    
-
-     Et les deux enfants se riaient l&#39;un &#224; l&#39;autre
+ Et les deux enfants se riaient l&#39;un &#224; l&#39;autre
     fraternellement, avec des
-
-     dents d&#39;une &#233;gale blancheur.
+ dents d&#39;une &#233;gale blancheur.
   </VerbatimFormatted>
   <Para start_line="35">
     [end]
diff --git a/t/corpus/lat1frim.xml b/t/corpus/lat1frim.xml
index ffbbdb0..18bec6f 100644
--- a/t/corpus/lat1frim.xml
+++ b/t/corpus/lat1frim.xml
@@ -23,10 +23,8 @@
     celui-ci examinait avidement comme un objet rare et inconnu.
     Or, ce joujou, que le petit souillon aga&#231;ait, agitait
     et secouait dans une bo&#238;te grill&#233;e, c&#39;&#233;tait
-    un rat vivant
-    &#160;
-    ! Les parents, par &#233;conomie sans doute, avaient tir&#233;
-    le joujou de la vie elle-m&#234;me.
+    un rat vivant&#160;! Les parents, par &#233;conomie sans
+    doute, avaient tir&#233; le joujou de la vie elle-m&#234;me.
   </Para>
   <Para start_line="18">
     Et les deux enfants se riaient l&#39;un &#224; l&#39;autre
@@ -42,27 +40,19 @@
   <VerbatimFormatted start_line="23" xml:space="preserve">
      A travers ces barreaux symboliques s&#233;parant deux mondes,
     la grande route
-
-     et le ch&#226;teau, l&#39;enfant pauvre montrait &#224;
+ et le ch&#226;teau, l&#39;enfant pauvre montrait &#224;
     l&#39;enfant riche son propre
-
-     joujou, que celui-ci examinait avidement comme un objet
+ joujou, que celui-ci examinait avidement comme un objet
     rare et inconnu.
-
-     Or, ce joujou, que le petit souillon aga&#231;ait, agitait
+ Or, ce joujou, que le petit souillon aga&#231;ait, agitait
     et secouait dans
-
-     une bo&#238;te grill&#233;e, c&#39;&#233;tait un rat vivant&#160;!
+ une bo&#238;te grill&#233;e, c&#39;&#233;tait un rat vivant&#160;!
     Les parents, par &#233;conomie
+ sans doute, avaient tir&#233; le joujou de la vie elle-m&#234;me. 
 
-     sans doute, avaient tir&#233; le joujou de la vie elle-m&#234;me. 
-
-    
-
-     Et les deux enfants se riaient l&#39;un &#224; l&#39;autre
+ Et les deux enfants se riaient l&#39;un &#224; l&#39;autre
     fraternellement, avec des
-
-     dents d&#39;une &#233;gale blancheur.
+ dents d&#39;une &#233;gale blancheur.
   </VerbatimFormatted>
   <Para start_line="33">
     [end]
diff --git a/t/corpus/pasternak_cp1251.xml b/t/corpus/pasternak_cp1251.xml
index 2276551..2243915 100644
--- a/t/corpus/pasternak_cp1251.xml
+++ b/t/corpus/pasternak_cp1251.xml
@@ -96,113 +96,71 @@
   <VerbatimFormatted start_line="61" xml:space="preserve">
       &#1047;&#1080;&#1084;&#1085;&#1103;&#1103; &#1085;&#1086;&#1095;&#1100;.
 
-    
-
-      &#1052;&#1077;&#1083;&#1086;, &#1084;&#1077;&#1083;&#1086;
+  &#1052;&#1077;&#1083;&#1086;, &#1084;&#1077;&#1083;&#1086;
     &#1087;&#1086; &#1074;&#1089;&#1077;&#1081; &#1079;&#1077;&#1084;&#1083;&#1077;
-
-      &#1042;&#1086; &#1074;&#1089;&#1077; &#1087;&#1088;&#1077;&#1076;&#1077;&#1083;&#1099;.
-
-      &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;
+  &#1042;&#1086; &#1074;&#1089;&#1077; &#1087;&#1088;&#1077;&#1076;&#1077;&#1083;&#1099;.
+  &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;
     &#1085;&#1072; &#1089;&#1090;&#1086;&#1083;&#1077;,
+  &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;.
 
-      &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;.
-
-    
-
-      &#1050;&#1072;&#1082; &#1083;&#1077;&#1090;&#1086;&#1084;
+  &#1050;&#1072;&#1082; &#1083;&#1077;&#1090;&#1086;&#1084;
     &#1088;&#1086;&#1077;&#1084; &#1084;&#1086;&#1096;&#1082;&#1086;&#1088;&#1072;
-
-      &#1051;&#1077;&#1090;&#1080;&#1090; &#1085;&#1072; &#1087;&#1083;&#1072;&#1084;&#1103;,
-
-      &#1057;&#1083;&#1077;&#1090;&#1072;&#1083;&#1080;&#1089;&#1100;
+  &#1051;&#1077;&#1090;&#1080;&#1090; &#1085;&#1072; &#1087;&#1083;&#1072;&#1084;&#1103;,
+  &#1057;&#1083;&#1077;&#1090;&#1072;&#1083;&#1080;&#1089;&#1100;
     &#1093;&#1083;&#1086;&#1087;&#1100;&#1103; &#1089;&#1086;
     &#1076;&#1074;&#1086;&#1088;&#1072;
-
-      &#1050; &#1086;&#1082;&#1086;&#1085;&#1085;&#1086;&#1081;
+  &#1050; &#1086;&#1082;&#1086;&#1085;&#1085;&#1086;&#1081;
     &#1088;&#1072;&#1084;&#1077;.
 
-    
-
-      &#1052;&#1077;&#1090;&#1077;&#1083;&#1100; &#1083;&#1077;&#1087;&#1080;&#1083;&#1072;
+  &#1052;&#1077;&#1090;&#1077;&#1083;&#1100; &#1083;&#1077;&#1087;&#1080;&#1083;&#1072;
     &#1085;&#1072; &#1089;&#1090;&#1086;&#1083;&#1077;
-
-      &#1050;&#1088;&#1091;&#1078;&#1082;&#1080; &#1080; &#1089;&#1090;&#1088;&#1077;&#1083;&#1099;.
-
-      &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;
+  &#1050;&#1088;&#1091;&#1078;&#1082;&#1080; &#1080; &#1089;&#1090;&#1088;&#1077;&#1083;&#1099;.
+  &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;
     &#1085;&#1072; &#1089;&#1090;&#1086;&#1083;&#1077;,
+  &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;.
 
-      &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;.
-
-    
-
-      &#1053;&#1072; &#1086;&#1079;&#1072;&#1088;&#1077;&#1085;&#1085;&#1099;&#1081;
+  &#1053;&#1072; &#1086;&#1079;&#1072;&#1088;&#1077;&#1085;&#1085;&#1099;&#1081;
     &#1087;&#1086;&#1090;&#1086;&#1083;&#1086;&#1082;
-
-      &#1051;&#1086;&#1078;&#1080;&#1083;&#1080;&#1089;&#1100;
+  &#1051;&#1086;&#1078;&#1080;&#1083;&#1080;&#1089;&#1100;
     &#1090;&#1077;&#1085;&#1080;,
-
-      &#1057;&#1082;&#1088;&#1077;&#1097;&#1077;&#1085;&#1100;&#1103;
+  &#1057;&#1082;&#1088;&#1077;&#1097;&#1077;&#1085;&#1100;&#1103;
     &#1088;&#1091;&#1082;, &#1089;&#1082;&#1088;&#1082;&#1097;&#1077;&#1085;&#1100;&#1103;
     &#1085;&#1086;&#1075;,
+  &#1057;&#1091;&#1076;&#1100;&#1073;&#1099; &#1089;&#1082;&#1088;&#1077;&#1097;&#1077;&#1085;&#1100;&#1103;.
 
-      &#1057;&#1091;&#1076;&#1100;&#1073;&#1099; &#1089;&#1082;&#1088;&#1077;&#1097;&#1077;&#1085;&#1100;&#1103;.
-
-    
-
-      &#1048; &#1087;&#1072;&#1076;&#1072;&#1083;&#1080; &#1076;&#1074;&#1072;
+  &#1048; &#1087;&#1072;&#1076;&#1072;&#1083;&#1080; &#1076;&#1074;&#1072;
     &#1073;&#1072;&#1096;&#1084;&#1072;&#1095;&#1082;&#1072;
-
-      &#1057;&#1086; &#1089;&#1090;&#1091;&#1082;&#1086;&#1084;
+  &#1057;&#1086; &#1089;&#1090;&#1091;&#1082;&#1086;&#1084;
     &#1085;&#1072; &#1087;&#1086;&#1083;,
-
-      &#1048; &#1074;&#1086;&#1089;&#1082; &#1089;&#1083;&#1077;&#1079;&#1072;&#1084;&#1080;
+  &#1048; &#1074;&#1086;&#1089;&#1082; &#1089;&#1083;&#1077;&#1079;&#1072;&#1084;&#1080;
     &#1089; &#1085;&#1086;&#1095;&#1085;&#1080;&#1082;&#1072;
-
-      &#1053;&#1072; &#1087;&#1083;&#1072;&#1090;&#1100;&#1077;
+  &#1053;&#1072; &#1087;&#1083;&#1072;&#1090;&#1100;&#1077;
     &#1082;&#1072;&#1087;&#1072;&#1083;.
 
-    
-
-      &#1048; &#1074;&#1089;&#1077; &#1090;&#1077;&#1088;&#1103;&#1083;&#1086;&#1089;&#1100;
+  &#1048; &#1074;&#1089;&#1077; &#1090;&#1077;&#1088;&#1103;&#1083;&#1086;&#1089;&#1100;
     &#1074; &#1089;&#1085;&#1077;&#1078;&#1085;&#1086;&#1081;
     &#1084;&#1075;&#1083;&#1077;
-
-      &#1057;&#1077;&#1076;&#1086;&#1081; &#1080; &#1073;&#1077;&#1083;&#1086;&#1081;.
-
-      &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;
+  &#1057;&#1077;&#1076;&#1086;&#1081; &#1080; &#1073;&#1077;&#1083;&#1086;&#1081;.
+  &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;
     &#1085;&#1072; &#1089;&#1090;&#1086;&#1083;&#1077;,
+  &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;.
 
-      &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;.
-
-    
-
-      &#1053;&#1072; &#1089;&#1074;&#1077;&#1095;&#1082;&#1091;
+  &#1053;&#1072; &#1089;&#1074;&#1077;&#1095;&#1082;&#1091;
     &#1076;&#1091;&#1083;&#1086; &#1080;&#1079; &#1091;&#1075;&#1083;&#1072;,
-
-      &#1048; &#1078;&#1072;&#1088; &#1089;&#1086;&#1073;&#1083;&#1072;&#1079;&#1085;&#1072;
-
-      &#1042;&#1079;&#1076;&#1099;&#1084;&#1072;&#1083;, &#1082;&#1072;&#1082;
+  &#1048; &#1078;&#1072;&#1088; &#1089;&#1086;&#1073;&#1083;&#1072;&#1079;&#1085;&#1072;
+  &#1042;&#1079;&#1076;&#1099;&#1084;&#1072;&#1083;, &#1082;&#1072;&#1082;
     &#1072;&#1085;&#1075;&#1077;&#1083;, &#1076;&#1074;&#1072;
     &#1082;&#1088;&#1099;&#1083;&#1072;
+  &#1050;&#1088;&#1077;&#1089;&#1090;&#1086;&#1086;&#1073;&#1088;&#1072;&#1079;&#1085;&#1086;.
 
-      &#1050;&#1088;&#1077;&#1089;&#1090;&#1086;&#1086;&#1073;&#1088;&#1072;&#1079;&#1085;&#1086;.
-
-    
-
-      &#1052;&#1077;&#1083;&#1086; &#1074;&#1077;&#1089;&#1100;
+  &#1052;&#1077;&#1083;&#1086; &#1074;&#1077;&#1089;&#1100;
     &#1084;&#1077;&#1089;&#1103;&#1094; &#1074; &#1092;&#1077;&#1074;&#1088;&#1072;&#1083;&#1077;,
-
-      &#1048; &#1090;&#1086; &#1080; &#1076;&#1077;&#1083;&#1086;
-
-      &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;
+  &#1048; &#1090;&#1086; &#1080; &#1076;&#1077;&#1083;&#1086;
+  &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;
     &#1085;&#1072; &#1089;&#1090;&#1086;&#1083;&#1077;,
+  &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;.
 
-      &#1057;&#1074;&#1077;&#1095;&#1072; &#1075;&#1086;&#1088;&#1077;&#1083;&#1072;.
-
-    
-
-      -- &#1041;&#1086;&#1088;&#1080;&#1089; &#1055;&#1072;&#1089;&#1090;&#1077;&#1088;&#1085;&#1072;&#1082;,
+  -- &#1041;&#1086;&#1088;&#1080;&#1089; &#1055;&#1072;&#1089;&#1090;&#1077;&#1088;&#1085;&#1072;&#1082;,
     1946
   </VerbatimFormatted>
   <Para start_line="105">
diff --git a/t/corpus/polish_utf8.xml b/t/corpus/polish_utf8.xml
index 1aa77ec..befbd1a 100644
--- a/t/corpus/polish_utf8.xml
+++ b/t/corpus/polish_utf8.xml
@@ -43,50 +43,28 @@
   </Para>
   <VerbatimFormatted start_line="41" xml:space="preserve">
       W&#347;r&#243;d nocnej ciszy g&#322;os si&#281; rozchodzi:
-
-      Wsta&#324;cie, pasterze, B&#243;g si&#281; nam rodzi!
-
-      Czym pr&#281;dzej si&#281; wybierajcie,
-
-      Do Betlejem pospieszajcie
-
-      Przywita&#263; Pana.
-
-    
-
-      Poszli, znale&#378;li Dzieci&#261;tko w &#380;&#322;obie
-
-      Z wszystkimi znaki danymi sobie.
-
-      Jako Bogu cze&#347;&#263; Mu dali,
-
-      A witaj&#261;c zawo&#322;ali
-
-      Z wielkiej rado&#347;ci:
-
-    
-
-      Ach, witaj Zbawco z dawno &#380;&#261;dany,
-
-      Wiele tysi&#281;cy lat wygl&#261;dany
-
-      Na Ciebie kr&#243;le, prorocy
-
-      Czekali, a Ty&#347; tej nocy
-
-      Nam si&#281; objawi&#322;.
-
-    
-
-      I my czekamy na Ciebie, Pana,
-
-      A skoro przyjdziesz na g&#322;os kap&#322;ana,
-
-      Padniemy na twarz przed Tob&#261;,
-
-      Wierz&#261;c, &#380;e&#347; jest pod os&#322;on&#261;
-
-      Chleba i wina.
+  Wsta&#324;cie, pasterze, B&#243;g si&#281; nam rodzi!
+  Czym pr&#281;dzej si&#281; wybierajcie,
+  Do Betlejem pospieszajcie
+  Przywita&#263; Pana.
+
+  Poszli, znale&#378;li Dzieci&#261;tko w &#380;&#322;obie
+  Z wszystkimi znaki danymi sobie.
+  Jako Bogu cze&#347;&#263; Mu dali,
+  A witaj&#261;c zawo&#322;ali
+  Z wielkiej rado&#347;ci:
+
+  Ach, witaj Zbawco z dawno &#380;&#261;dany,
+  Wiele tysi&#281;cy lat wygl&#261;dany
+  Na Ciebie kr&#243;le, prorocy
+  Czekali, a Ty&#347; tej nocy
+  Nam si&#281; objawi&#322;.
+
+  I my czekamy na Ciebie, Pana,
+  A skoro przyjdziesz na g&#322;os kap&#322;ana,
+  Padniemy na twarz przed Tob&#261;,
+  Wierz&#261;c, &#380;e&#347; jest pod os&#322;on&#261;
+  Chleba i wina.
   </VerbatimFormatted>
   <Para start_line="65">
     [end]
diff --git a/t/corpus/thai_iso11.xml b/t/corpus/thai_iso11.xml
index a9f4bb7..263ef8e 100644
--- a/t/corpus/thai_iso11.xml
+++ b/t/corpus/thai_iso11.xml
@@ -49,43 +49,25 @@
   </Para>
   <VerbatimFormatted start_line="40" xml:space="preserve">
         &#3663; &#3614;&#3619;&#3632;&#3648;&#3617;&#3605;&#3605;&#3634;&#3649;&#3592;&#3656;&#3617;&#3592;&#3633;&#3610;&#3651;&#3592;&#3652;&#3612;&#3607;&#3626;&#3618;&#3634;&#3617;
-
-        &#3614;&#3619;&#3632;&#3607;&#3633;&#3618;&#3591;&#3634;&#3617;...&#3617;&#3629;&#3591;&#3616;&#3634;&#3614;&#3606;&#3656;&#3634;&#3618;&#3617;&#3636;&#3606;&#3656;&#3634;&#3618;&#3606;&#3629;&#3609;
-
-        &#3648;&#3585;&#3621;&#3657;&#3634;&#3631; &#3609;&#3657;&#3629;&#3617;&#3648;&#3585;&#3621;&#3657;&#3634;&#3631;
+    &#3614;&#3619;&#3632;&#3607;&#3633;&#3618;&#3591;&#3634;&#3617;...&#3617;&#3629;&#3591;&#3616;&#3634;&#3614;&#3606;&#3656;&#3634;&#3618;&#3617;&#3636;&#3606;&#3656;&#3634;&#3618;&#3606;&#3629;&#3609;
+    &#3648;&#3585;&#3621;&#3657;&#3634;&#3631; &#3609;&#3657;&#3629;&#3617;&#3648;&#3585;&#3621;&#3657;&#3634;&#3631;
     &#3614;&#3592;&#3609;&#3660;&#3648;&#3619;&#3637;&#3618;&#3591;&#3648;&#3612;&#3604;&#3637;&#3618;&#3591;&#3585;&#3621;&#3629;&#3609;
+    &#3626;&#3639;&#3656;&#3629;&#3626;&#3632;&#3607;&#3657;&#3629;&#3609;&#3614;&#3619;&#3632;&#3585;&#3634;&#3619;&#3640;&#3603;&#3618;&#3660;&#3629;&#3640;&#3656;&#3609;&#3604;&#3623;&#3591;&#3617;&#3634;&#3609;&#3674;
 
-        &#3626;&#3639;&#3656;&#3629;&#3626;&#3632;&#3607;&#3657;&#3629;&#3609;&#3614;&#3619;&#3632;&#3585;&#3634;&#3619;&#3640;&#3603;&#3618;&#3660;&#3629;&#3640;&#3656;&#3609;&#3604;&#3623;&#3591;&#3617;&#3634;&#3609;&#3674;
-
-    
-
-        &#3663; &#3607;&#3640;&#3585;&#3616;&#3634;&#3614;&#3617;&#3636;&#3656;&#3591;&#3617;&#3591;&#3588;&#3621;&#3618;&#3621;&#3649;&#3621;&#3657;&#3623;&#3618;&#3636;&#3657;&#3617;
-
-        &#3648;&#3629;&#3639;&#3657;&#3629;&#3629;&#3585;&#3629;&#3636;&#3656;&#3617;&#3621;&#3657;&#3635;&#3588;&#3656;&#3634;&#3617;&#3627;&#3634;&#3624;&#3634;&#3621;
-
-        &#3629;&#3618;&#3634;&#3585;&#3648;&#3611;&#3655;&#3609;&#3588;&#3640;&#3603;&#3607;&#3629;&#3591;&#3649;&#3604;&#3591;&#3609;&#3633;&#3585;&#3592;&#3633;&#3585;&#3629;&#3618;&#3641;&#3656;&#3591;&#3634;&#3609;
-
-        &#3648;&#3613;&#3657;&#3634;&#3588;&#3621;&#3629;&#3648;&#3588;&#3621;&#3637;&#3618;&#3610;&#3607;&#3617;&#3634;&#3621;&#3618;&#3660;&#3614;&#3619;&#3632;&#3616;&#3641;&#3617;&#3636;&#3614;&#3621;&#3674;
-
-    
-
-        &#3663; &#3614;&#3619;&#3632;&#3627;&#3633;&#3605;&#3606;&#3660;&#3610;&#3640;&#3597;&#3607;&#3619;&#3591;&#3648;&#3610;&#3636;&#3585;&#3627;&#3621;&#3657;&#3634;&#3614;&#3621;&#3636;&#3585;&#3627;&#3621;&#3657;&#3634;&#3648;&#3586;&#3637;&#3618;&#3623;
-
-        &#3614;&#3619;&#3632;&#3650;&#3629;&#3625;&#3600;&#3660;&#3648;&#3619;&#3637;&#3618;&#3623;&#3605;&#3619;&#3633;&#3626;&#3627;&#3657;&#3634;&#3617;&#3626;&#3591;&#3588;&#3619;&#3634;&#3617;&#3593;&#3621;
-
-        &#3614;&#3619;&#3632;&#3607;&#3633;&#3618; &#3608; &#3650;&#3629;&#3616;&#3634;&#3626;&#3612;&#3656;&#3629;&#3591;&#3606;&#3656;&#3629;&#3591;&#3626;&#3585;&#3621;
-
-        &#3614;&#3619;&#3632;&#3618;&#3640;&#3588;&#3621;&#3610;&#3634;&#3607;&#3618;&#3656;&#3634;&#3591;&#3626;&#3639;&#3610;&#3626;&#3619;&#3657;&#3634;&#3591;&#3652;&#3607;&#3618;&#3674;
-
-    
-
-        &#3663; &#3609;&#3657;&#3629;&#3617;&#3648;&#3585;&#3621;&#3657;&#3634;&#3648;&#3607;&#3636;&#3604;&#3629;&#3591;&#3588;&#3660;&#3619;&#3634;&#3594;&#3633;&#3609;&#3624;&#3619;&#3633;&#3609;&#3618;&#3660;&#3624;&#3619;&#3637;
-
-        &#3610;&#3634;&#3619;&#3617;&#3637;&#3627;&#3617;&#3639;&#3656;&#3609;&#3588;&#3641;&#3656;&#3588;&#3591;&#3629;&#3626;&#3591;&#3652;&#3586;&#3618;
+    &#3663; &#3607;&#3640;&#3585;&#3616;&#3634;&#3614;&#3617;&#3636;&#3656;&#3591;&#3617;&#3591;&#3588;&#3621;&#3618;&#3621;&#3649;&#3621;&#3657;&#3623;&#3618;&#3636;&#3657;&#3617;
+    &#3648;&#3629;&#3639;&#3657;&#3629;&#3629;&#3585;&#3629;&#3636;&#3656;&#3617;&#3621;&#3657;&#3635;&#3588;&#3656;&#3634;&#3617;&#3627;&#3634;&#3624;&#3634;&#3621;
+    &#3629;&#3618;&#3634;&#3585;&#3648;&#3611;&#3655;&#3609;&#3588;&#3640;&#3603;&#3607;&#3629;&#3591;&#3649;&#3604;&#3591;&#3609;&#3633;&#3585;&#3592;&#3633;&#3585;&#3629;&#3618;&#3641;&#3656;&#3591;&#3634;&#3609;
+    &#3648;&#3613;&#3657;&#3634;&#3588;&#3621;&#3629;&#3648;&#3588;&#3621;&#3637;&#3618;&#3610;&#3607;&#3617;&#3634;&#3621;&#3618;&#3660;&#3614;&#3619;&#3632;&#3616;&#3641;&#3617;&#3636;&#3614;&#3621;&#3674;
 
-        &#3585;&#3619;&#3619;&#3604;&#3636;&#3619;&#3634;&#3594;&#3585;&#3620;&#3625;&#3598;&#3634;&#3585;&#3657;&#3629;&#3591;&#3627;&#3621;&#3657;&#3634;&#3652;&#3585;&#3621;
+    &#3663; &#3614;&#3619;&#3632;&#3627;&#3633;&#3605;&#3606;&#3660;&#3610;&#3640;&#3597;&#3607;&#3619;&#3591;&#3648;&#3610;&#3636;&#3585;&#3627;&#3621;&#3657;&#3634;&#3614;&#3621;&#3636;&#3585;&#3627;&#3621;&#3657;&#3634;&#3648;&#3586;&#3637;&#3618;&#3623;
+    &#3614;&#3619;&#3632;&#3650;&#3629;&#3625;&#3600;&#3660;&#3648;&#3619;&#3637;&#3618;&#3623;&#3605;&#3619;&#3633;&#3626;&#3627;&#3657;&#3634;&#3617;&#3626;&#3591;&#3588;&#3619;&#3634;&#3617;&#3593;&#3621;
+    &#3614;&#3619;&#3632;&#3607;&#3633;&#3618; &#3608; &#3650;&#3629;&#3616;&#3634;&#3626;&#3612;&#3656;&#3629;&#3591;&#3606;&#3656;&#3629;&#3591;&#3626;&#3585;&#3621;
+    &#3614;&#3619;&#3632;&#3618;&#3640;&#3588;&#3621;&#3610;&#3634;&#3607;&#3618;&#3656;&#3634;&#3591;&#3626;&#3639;&#3610;&#3626;&#3619;&#3657;&#3634;&#3591;&#3652;&#3607;&#3618;&#3674;
 
-        &#3611;&#3621;&#3639;&#3657;&#3617;&#3611;&#3619;&#3632;&#3607;&#3633;&#3610;&#3606;&#3657;&#3623;&#3609;&#3607;&#3640;&#3585;&#3651;&#3592;&#3649;&#3627;&#3656;&#3591;&#3652;&#3607;&#3657;&#3648;&#3629;&#3618;&#3674;&#3632;&#3675;
+    &#3663; &#3609;&#3657;&#3629;&#3617;&#3648;&#3585;&#3621;&#3657;&#3634;&#3648;&#3607;&#3636;&#3604;&#3629;&#3591;&#3588;&#3660;&#3619;&#3634;&#3594;&#3633;&#3609;&#3624;&#3619;&#3633;&#3609;&#3618;&#3660;&#3624;&#3619;&#3637;
+    &#3610;&#3634;&#3619;&#3617;&#3637;&#3627;&#3617;&#3639;&#3656;&#3609;&#3588;&#3641;&#3656;&#3588;&#3591;&#3629;&#3626;&#3591;&#3652;&#3586;&#3618;
+    &#3585;&#3619;&#3619;&#3604;&#3636;&#3619;&#3634;&#3594;&#3585;&#3620;&#3625;&#3598;&#3634;&#3585;&#3657;&#3629;&#3591;&#3627;&#3621;&#3657;&#3634;&#3652;&#3585;&#3621;
+    &#3611;&#3621;&#3639;&#3657;&#3617;&#3611;&#3619;&#3632;&#3607;&#3633;&#3610;&#3606;&#3657;&#3623;&#3609;&#3607;&#3640;&#3585;&#3651;&#3592;&#3649;&#3627;&#3656;&#3591;&#3652;&#3607;&#3657;&#3648;&#3629;&#3618;&#3674;&#3632;&#3675;
   </VerbatimFormatted>
   <Para start_line="60">
     [end]
diff --git a/t/x_nixer.t b/t/x_nixer.t
index f435187..92917df 100644
--- a/t/x_nixer.t
+++ b/t/x_nixer.t
@@ -44,9 +44,7 @@ ok( Pod::Simple::DumpAsXML->_out( "=pod\n\nZ<>F<C<Z<>fE<111>o> I<bar>> B<stuff X
   '  <Para>',
   '    <F>',
   '      <C>',
-  '        f',
-  '        o',
-  '        o',
+  '        foo',
   '      </C>',
   '       ',
   '      <I>',
@@ -77,9 +75,7 @@ ok( Pod::Simple::DumpAsXML->_out( \&nixy, "=pod\n\nZ<>F<C<Z<>fE<111>o> I<bar>> B
   '  <Para>',
   '    <F>',
   '      <C>',
-  '        f',
-  '        o',
-  '        o',
+  '        foo',
   '      </C>',
   '       ',
   '      <I>',
@@ -88,8 +84,7 @@ ok( Pod::Simple::DumpAsXML->_out( \&nixy, "=pod\n\nZ<>F<C<Z<>fE<111>o> I<bar>> B
   '    </F>',
   '     ',
   '    <B>',
-  '      stuff ',
-  '      baz',
+  '      stuff baz',
   '    </B>',
   '  </Para>',
   '</Document>',
-- 
1.7.5.4
0002-Introduce-handle_code-method.patch (application/octet-stream, 3.7 KB)
From 9cafd6c5dd1aa753ba0dc698324b1fe6ef05274d Mon Sep 17 00:00:00 2001
From: Gisle Aas <[email protected]>
Date: Sat, 21 Apr 2012 16:27:03 +0200
Subject: [PATCH 2/2] Introduce handle_code method

---
 lib/Pod/Simple/XHTML.pm |   22 ++++++++++++++++++----
 t/xhtml01.t             |    2 +-
 t/xhtml20.t             |   41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 5 deletions(-)
 create mode 100644 t/xhtml20.t

diff --git a/lib/Pod/Simple/XHTML.pm b/lib/Pod/Simple/XHTML.pm
index efa9b11..0489274 100644
--- a/lib/Pod/Simple/XHTML.pm
+++ b/lib/Pod/Simple/XHTML.pm
@@ -305,6 +305,12 @@ something like:
       $self->SUPER::handle_text($text);
   }
 
+=head2 handle_code
+
+This method handles the body of text that is marked up to be code.
+You might want to override this to for instance plug in a syntax highlighter.
+The base implementation just escapes the text and wraps it in C<<< <code>...</code> >>>.
+
 =head2 accept_targets_as_html
 
 This method behaves like C<accept_targets_as_text>, but also marks the region
@@ -326,14 +332,21 @@ sub accept_targets_as_html {
 }
 
 sub handle_text {
+    if ($_[0]{'in_code'}) {
+	return $_[0]->handle_code( $_[1] );
+    }
     # escape special characters in HTML (<, >, &, etc)
     $_[0]{'scratch'} .= $_[0]->__in_literal_xhtml_region
                       ? $_[1]
                       : $_[0]->encode_entities( $_[1] );
 }
 
+sub handle_code {
+    $_[0]{'scratch'} .= '<code>' . $_[0]->encode_entities( $_[1] ) . '</code>';
+}
+
 sub start_Para     { $_[0]{'scratch'} = '<p>' }
-sub start_Verbatim { $_[0]{'scratch'} = '<pre><code>' }
+sub start_Verbatim { $_[0]{'scratch'} = '<pre>'; $_[0]{'in_code'} = 1; }
 
 sub start_head1 {  $_[0]{'in_head'} = 1 }
 sub start_head2 {  $_[0]{'in_head'} = 2 }
@@ -396,7 +409,8 @@ sub end_over_text   {
 
 sub end_Para     { $_[0]{'scratch'} .= '</p>'; $_[0]->emit }
 sub end_Verbatim {
-    $_[0]{'scratch'}     .= '</code></pre>';
+    $_[0]{'scratch'} .= '</pre>';
+    delete $_[0]{'in_code'};
     $_[0]->emit;
 }
 
@@ -567,8 +581,8 @@ sub end_Document   {
 sub start_B { $_[0]{'scratch'} .= '<b>' }
 sub end_B   { $_[0]{'scratch'} .= '</b>' }
 
-sub start_C { $_[0]{'scratch'} .= '<code>' }
-sub end_C   { $_[0]{'scratch'} .= '</code>' }
+sub start_C { $_[0]{'in_code'} = 1; }
+sub end_C   { delete $_[0]{'in_code'}; }
 
 sub start_F { $_[0]{'scratch'} .= '<i>' }
 sub end_F   { $_[0]{'scratch'} .= '</i>' }
diff --git a/t/xhtml01.t b/t/xhtml01.t
index 27860d8..07a746b 100644
--- a/t/xhtml01.t
+++ b/t/xhtml01.t
@@ -667,7 +667,7 @@ SKIP: for my $use_html_entities (0, 1) {
 EOPOD
 is($results, <<"EOHTML", "Verbatim text with markup and embedded formatting");
 <pre><code>  # this header is very important &amp; dont you forget it
-  <b>my \$file = &lt;FILE&gt; || Blank!;</b>
+  </code><b><code>my \$file = &lt;FILE&gt; || Blank!;</code></b><code>
   my \$text = &quot;File is: &quot; . &lt;FILE&gt;;</code></pre>
 
 EOHTML
diff --git a/t/xhtml20.t b/t/xhtml20.t
new file mode 100644
index 0000000..06a05ae
--- /dev/null
+++ b/t/xhtml20.t
@@ -0,0 +1,41 @@
+#!/usr/bin/perl -w
+
+# t/xhtml20.t - test subclassing of Pod::Simple::XHTML
+
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+BEGIN {
+    package MyXHTML;
+    use base 'Pod::Simple::XHTML';
+
+    sub handle_code {
+	my($self, $code) = @_;
+	$code = "[$code]";
+	$self->SUPER::handle_code($code);
+    }
+}
+
+
+
+my ($parser, $results);
+
+initialize();
+$parser->parse_string_document(<<'EOT');
+=head1 Foo
+
+This is C<$code> and so is:
+
+  my $foo = 1;
+EOT
+
+like $results, qr/<code>\[\$code]<\/code>/;
+like $results , qr/<pre><code>\[  my \$foo = 1;/;
+
+
+sub initialize {
+    $parser = MyXHTML->new;
+    $parser->output_string( \$results );
+    $results = '';
+}
-- 
1.7.5.4
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.