my ($title, $cells) = @{$row};
printf '<tr id="%s">', (lc $title) =~ s/<[^>]+>//gr =~ s/\s+/-/gr;
say '<th>', $title;
- say "\t", '<td>' x !/^<td/, $_ for @{$cells};
+ my $colspan = 1;
+ for (@{$cells}) {
+ if ($_ eq '>') {
+ $colspan++;
+ next;
+ }
+ print "\t<td";
+ if ($colspan > 1) {
+ print " colspan=$colspan";
+ $colspan = 1;
+ }
+ print '>' unless s/^<td//;
+ say;
+ }
}
say "</table>\n";
}