clean up the list[] construct when unformatting
authorTony Cook <tony@develop-help.com>
Mon, 20 Jan 2014 07:34:54 +0000 (18:34 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 20 Jan 2014 07:34:54 +0000 (18:34 +1100)
site/cgi-bin/modules/DevHelp/Formatter.pm
t/010-modules/050-format.t

index 33fc16ae15f030c499c551bd13ebc61578db4a52..04b77672236444f6020eea331453a68d61e14b07 100644 (file)
@@ -538,6 +538,8 @@ sub remove_format {
          and next TRY;
        $part =~ s#table\[([^\]\[]+)\|([^\]\[|]+)\]#_cleanup_table($1, "|$2")#ieg
          and next TRY;
+       $part =~ s# ?\blist\[([^\]\[\|]*)\|\s*(\S[^\]\[]+)\]#$2#g
+         and next TRY;
        $part =~ s#\*\*([^\n]+)#$1#g
          and next TRY;
        $part =~ s!##([^\n]+)!$1!g
index 6196f085866d093df350830895f24c9d1a98187a..baf3c18ff9ce60f9eb861003daf712f569c56725 100644 (file)
@@ -1,6 +1,6 @@
 #!perl -w
 use strict;
-use Test::More tests => 150;
+use Test::More tests => 151;
 
 sub format_test($$$;$);
 sub noformat_test($$$;$);
@@ -868,6 +868,16 @@ OUT
   noformat_test '**image[bar]', '', '** list with image content';
   noformat_test '%%image[bar]', '', '%% list with image content';
   noformat_test '##image[bar]', '', '## list with image content';
+  noformat_test <<IN, <<OUT, "list[] no attr", "both";
+list[|
+## one
+## two
+]
+IN
+ one
+ two
+
+OUT
 }
 
 sub format_test ($$$;$) {