##
sub descend_htmltree {
my $node = shift;
my $withclickiness = shift || 0;
foreach my $tmpnode (@{$node}) {
if(ref($tmpnode) eq 'HASH') {
my $nodeid = ""; # Magic code to generate node's position in tree
$htmloutput .= "" if($withclickiness);
$htmloutput .= "<$tmpnode->{tag}";
foreach(keys %{$tmpnode}) {
$htmloutput .= " $_=\"$tmpnode->{$_}\"" if($_ ne 'tag' && $_ ne 'content');
}
$htmloutput .= ">";
descend_htmltree($tmpnode->{content});
$htmloutput .= "$tmpnode->{tag}>";
$htmloutput .= "
" if($withclickiness);
} else {
$htmloutput .= "$tmpnode";
}
}
}
sub htmltree_to_html {
my $filename = shift || '';
my $withclickiness = shift || 0;
descend_htmltree($htmltree->[0]->{content}, $withclickiness);
if($filename ne '') {
open HTML, "> $filename" or die "Can't open $filename for HTML output";
print HTML $htmloutput;
close HTML;
}
return $htmloutput;
}