sub story { my ($source,$author) = @_; my $tab = 3; my @toc; while (my $line = <$source>) { chomp($line); if ($line =~ /^2/) { my ($number,$text) = split(/ /,$line,2); push @toc, anchor($text, { href => '#'.idify($text) }); } } list($tab, 'u', \@toc, { class => 'two' }); # I ran $source above, so I can't have it here! /me head desks. while (my $line = <$source>) { chomp($line); # If a line starts with a bracket, just print the line. if ($line =~ m/^ $id }); } # If a line is a break or horizontal rule, print the line in brackets. elsif ($line =~ /^[bh]r$/) { line($tab,"<$line>"); } # All other lines are paragraphs. else { paragraph($tab,$line); } } # If I wrote a story, I want people to know I wrote it at the bottom. paragraph($tab,"written by $root_user", { class => 'author' }) if !$author; }