add newlines around hr tags
authorTony Cook <tony@develop-help.com>
Thu, 24 Oct 2013 04:19:15 +0000 (15:19 +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 9a49ac127f2ef385fdac8efd722a50328bff1ead..b54586a497d8c5817c6c205aa0fbf98f2f978cf2 100644 (file)
@@ -454,7 +454,8 @@ sub format {
       1 while $part =~ s#(<(?:$all_block_tags)[^>]*>)(<(?:$all_block_tags)\b)#$1\n$2#g;
       1 while $part =~ s#(</a>)(<a\s+[^>]*>)(<(?:$all_block_tags))#$1\n$2\n$3#g;
       1 while $part =~ s#(<a\s+[^>]*>)(<(?:$all_block_tags))#$1\n$2#g;
-      1 while $part =~ s#(<hr\b[^>]*/>)(<a\s+[^>]*>)#$1\n$2#g;
+      1 while $part =~ s#(>)(<hr\b[^>]*/>)#$1\n$2#g;
+      1 while $part =~ s#(<hr\b[^>]*/>)(<)#$1\n$2#g;
       #$part =~ s!<p>(<hr[^>]*>)</p>!$1!g;
       $part =~ s!<p>(<(?:table|ol|ul|center|h[1-6])[^>]*>)!$1!g;
       $part =~ s!(</(?:table|ol|ul|center|h[1-6])>)</p>!$1!g;
index a1f432ea297c45cdce0fe24dbf49457843a8eeb0..75b937339b855f38bed3bb34e39aaeccf130857c 100644 (file)
@@ -1,6 +1,6 @@
 #!perl -w
 use strict;
-use Test::More tests => 141;
+use Test::More tests => 142;
 
 sub format_test($$$;$);
 sub noformat_test($$$;$);
@@ -414,6 +414,17 @@ OUT
   format_test 'hr[]', '<hr />', 'hr0';
   format_test 'hr[80%]', '<hr width="80%" />', 'hr1';
   format_test 'hr[80%|10]', '<hr width="80%" size="10" />', 'hr2';
+  format_test <<'IN', <<'OUT', 'hr with other text', 'both';
+testhr[]test
+hr[80%]
+test
+IN
+<p>test</p>
+<hr />
+<p>test</p>
+<hr width="80%" />
+<p>test</p>
+OUT
   format_test <<IN, <<OUT, 'table1', 'both';
 table[80%
 bgcolor="black"|quux|blarg