<html>
<head>
  <link rel="stylesheet" type="text/css" href="pod.css">
  <%
    my $title = findvalue('/pod/head/title/text()');
  %>
  <title><%= $title %></title>
</head>
<body>

  <div id="toc">
    <p class="toctitle">Table of Contents</p>
    <ul class="toclist">
      <%
        my %toc   = ();
        my $count = 0;
        for my $sect1 (findnodes('/pod/sect1')) {
          my $name    = $sect1->findvalue('title/text()');
          $toc{$name} = ++$count;
          $name       =~ s/(\w+)/ucfirst(lc($1))/eg;
          print qq(<li><a href="#$count">$name</a></li>\n);
        }
      %>
    </ul>
  </div>

  <h1><%= $title %></h1>

  <%
    $t->{title}{testcode} = sub {
      my($node, $t) = @_;
      
      my $name   = findvalue('./text()', $node);
      my $parent = findvalue('name(..)', $node);
      if($parent =~ /sect(\d)/) {
        my $level  = $1;
        $t->{pre}  = qq(<h$level><a name="$toc{$name}">);
        $t->{post} = qq(</a></h$level>);
        return 1;
      }

      return 0;
    };

    $t->{xlink}{pre}     = '<a href="{@uri}">';
    $t->{xlink}{post}    = '</a>';

    $t->{para}{pre}      = '<p>';
    $t->{para}{post}     = '</p>';

    $t->{verbatim}{pre}  = '<pre>';
    $t->{verbatim}{post} = '</pre>';

    $t->{strong}{pre}    = '<b>';
    $t->{strong}{post}   = '</b>';

    $t->{filename}       = $t->{strong};

    $t->{emphasis}{pre}  = '<i>',;
    $t->{emphasis}{post} = '</i>';

    $t->{code}{pre}      = '<tt>';
    $t->{code}{post}     = '</tt>';

  %>
  <%= apply_templates() %>

  <p>&nbsp;</p>
  <p>&nbsp;</p>
</body>
</html>