sub cell { # $tab is a number. # $type is either 'h' for heading or 'd' for data. # $contents is the text in the cell. # $opt is all of the available options to be adding inside the opening tag. my ($tab,$type,$contents,$opt) = @_; my @attributes; push @attributes, qq(id="$opt->{id}") if $opt->{id}; push @attributes, qq(class="$opt->{class}") if $opt->{class}; push @attributes, qq(style="$opt->{style}") if $opt->{style}; push @attributes, qq(colspan="$opt->{colspan}") if $opt->{colspan}; push @attributes, qq(rowspan="$opt->{rowspan}") if $opt->{rowspan}; my $format = @attributes > 0 ? ' '.join(' ',@attributes) : ''; my $open = $type.$format; line($tab,qq()); # Lists are treated specially in cells. The list subroutine is below. if ($contents =~ /list/i) { if (ref($opt->{list}[1]) eq 'HASH') { list($tab + 1,$opt->{list}->[0],$opt->{list}->[1]); } else { list($tab + 1,$opt->{list}); } } else { line($tab + 1,$contents); } line($tab,qq()); }