- printf '<li%s>', defined $table{$row} && ' class="parent"';
- print showimg($row);
- printimgs(@{$_}) for $table{$row} // ();
+ my ($id, $level, $title) = @{$row};
+ $id or die "empty reference"; # assertion to prevent loops
+ my @type;
+ push @type, 'parent' if defined $table->{$id};
+ push @type, 'large' if $level =~ s/c$//;
+ push @type, 'level'.($level || 0);
+ printf '<li%s>', @type ? sprintf ' class="%s"', join ' ', @type : '';
+ print showimg($id, $title) if $level <= $limit;
+ printimgs(@{$_}) for $table->{$id} // ();