sub story { my ($source,$author) = @_; my $tab = 3; my $inc = 0; my @sections; my @toc; while (my $line = <$source>) { chomp($line); if ($line =~ /^2/) { $inc++; my ($number,$text) = split(/ /,$line,2); push @toc, anchor($text, { href => '#'.idify($text) }); } push @{$sections[$inc]}, $line; } list($tab, 'u', \@toc, { class => 'two' }) if @toc > 3; for my $section (@sections) { section($tab, sub { for my $line (@{$section}) { chomp($line); if ($line =~ m/^ $id }); } elsif ($line =~ /^[bh]r$/) { line($tab,"<$line>"); } else { paragraph($tab,$line); } } }); } paragraph($tab,"written by $root_user", { class => 'author' }) if !$author; }