fix list test failures and put list tags on their own lines
authorTony Cook <tony@develop-help.com>
Thu, 24 Oct 2013 04:30:11 +0000 (15:30 +1100)
committerTony Cook <tony@develop-help.com>
Sun, 3 Nov 2013 23:20:23 +0000 (10:20 +1100)
site/cgi-bin/modules/DevHelp/Formatter.pm
t/010-modules/050-format.t

index b54586a497d8c5817c6c205aa0fbf98f2f978cf2..dd9d71cccb9093e548f66b0313b1402f5790bd0e 100644 (file)
@@ -16,7 +16,7 @@ use constant NO_CP => "\x03";
 my @block_tags = qw(div address blockquote article section header footer aside nav figure figcaption);
 my $block_tags = join "|", @block_tags;
 
-my @all_block_tags = ( @block_tags, qw(h1 h2 h3 h4 h5 h6 p) );
+my @all_block_tags = ( @block_tags, qw(h1 h2 h3 h4 h5 h6 p li ol ul) );
 
 my $all_block_tags = join "|", @all_block_tags;
 
@@ -108,7 +108,7 @@ sub _format_bullets {
     $point =~ s!\n *$!!
       and $point = "<p>$point</p>";
   }
-  return "<ul><li>".join("</li><li>", @points)."</li></ul>";
+  return "\n\n" . NO_P . "<ul><li>".join("</li><li>", @points)."</li></ul>" . NO_CP . "\n\n";
 }
 
 # make a OL
@@ -129,7 +129,7 @@ sub _format_ol {
   my $ol = "<ol";
   $ol .= qq! type="$type"! if $type;
   $ol .= ">";
-  return "$ol<li>".join("</li><li>", @points)."</li></ol>";
+  return "\n\n" . NO_P . "$ol<li>".join("</li><li>", @points)."</li></ol>" . NO_CP . "\n\n";
 }
 
 sub _format_lists {
index 75b937339b855f38bed3bb34e39aaeccf130857c..9654686748987caefbe1d67292152a9f22fbf50d 100644 (file)
@@ -281,7 +281,10 @@ there]
 foo]
 IN
 <blockquote>
-<ul><li>one</li><li>two</li></ul>
+<ul>
+<li>one</li>
+<li>two</li>
+</ul>
 <h1>quux</h1>
 <p><var>hello<br />
 there</var></p>
@@ -450,47 +453,74 @@ OUT
 ## one
 ## two
 IN
-<ol><li>one</li><li>two</li></ol>
+<ol>
+<li>one</li>
+<li>two</li>
+</ol>
 OUT
   format_test <<IN, <<OUT, 'ol2', 'both';
 ## one
 
 ## two
 IN
-<ol><li><p>one</p></li><li>two</li></ol>
+<ol>
+<li>
+<p>one</p>
+</li>
+<li>two</li>
+</ol>
 OUT
   format_test <<IN, <<OUT, 'ol1 alpha', 'both';
 %% one
 %% two
 IN
-<ol type="a"><li>one</li><li>two</li></ol>
+<ol type="a">
+<li>one</li>
+<li>two</li>
+</ol>
 OUT
   format_test <<IN, <<OUT, 'ol2 alpha', 'both';
 %% one
 
 %% two
 IN
-<ol type="a"><li><p>one</p></li><li>two</li></ol>
+<ol type="a">
+<li>
+<p>one</p>
+</li>
+<li>two</li>
+</ol>
 OUT
   format_test <<IN, <<OUT, 'ul1', 'both';
 ** one
 ** two
 IN
-<ul><li>one</li><li>two</li></ul>
+<ul>
+<li>one</li>
+<li>two</li>
+</ul>
 OUT
   format_test <<IN, <<OUT, 'ul2', 'both';
 ** one
 
 ** two
 IN
-<ul><li><p>one</p></li><li>two</li></ul>
+<ul>
+<li>
+<p>one</p>
+</li>
+<li>two</li>
+</ul>
 OUT
 
   format_test <<IN, <<OUT, 'ul indented', 'both';
   ** one
 **two
 IN
-<ul><li>one</li><li>two</li></ul>
+<ul>
+<li>one</li>
+<li>two</li>
+</ul>
 OUT
 
   format_test <<IN, <<OUT, "don't ul at end of line", 'both';
@@ -500,7 +530,10 @@ this shouldn't be a bullet ** some text
 ** so should this
 IN
 <p>this shouldn't be a bullet ** some text</p>
-<ul><li>this should be a bullet</li><li>so should this</li></ul>
+<ul>
+<li>this should be a bullet</li>
+<li>so should this</li>
+</ul>
 OUT
 
   format_test <<IN, <<OUT, 'mixed', 'both';
@@ -509,7 +542,14 @@ OUT
 ## one
 ## two
 IN
-<ul><li>joe</li><li>bob</li></ul><ol><li>one</li><li>two</li></ol>
+<ul>
+<li>joe</li>
+<li>bob</li>
+</ul>
+<ol>
+<li>one</li>
+<li>two</li>
+</ol>
 OUT
 
   format_test <<IN, <<OUT, 'spaces between', 'both';
@@ -519,7 +559,15 @@ OUT
 
 ** jane
 IN
-<ul><li><p>joe</p></li><li><p>bob</p></li><li>jane</li></ul>
+<ul>
+<li>
+<p>joe</p>
+</li>
+<li>
+<p>bob</p>
+</li>
+<li>jane</li>
+</ul>
 OUT
 
   format_test 'indent[text]', '<ul>text</ul>', 'indent';
@@ -685,7 +733,10 @@ div[#id|
 ]
 IN
 <div id="id">
-<ul><li>item</li><li>item</li></ul>
+<ul>
+<li>item</li>
+<li>item</li>
+</ul>
 </div>
 OUT