{  # No my/our in front of $q_tag or it will leave scope too soon!
  $q_tag = html_quote($tag);
  head("Lintian Tag: ${q_tag}") }
  <h1><span class="type-{$code}">{$code}</span> {${q_tag}}</h1>

{ if ($statistics{total} <= $shown_count) {
  $OUT .= qq(
  <p>
    All reports of ${tag} for the archive. The extended description of this
    tag is:
  </p>
);
  } else {
  my $log_link = resource_path('lintian.log.gz');
  $OUT .= qq(
    <p>
      A subset of the reports of ${tag} for the archive.  Unfortunately the full
      list is too long, so only ${shown_count} instances are listed on this page.
      At most ${tag_limit_per_package} tags are shown per package.
      <a href="${log_link}">If you need the full list of tags,
       please download the lintian.log.gz file and extract the data you need.</a>
    </p>
    <p>
      The extended description of this tag is:
    </p>
  );
  }
}

  <blockquote class="type-{$code}">
{$description}
  </blockquote>

{
    if ($graphs) {
        my $graph_link = resource_path("${tag}.svg");
        $OUT .= qq(  <p>\n);
        $OUT .= qq(    Evolution of the ${q_tag} Lintian tag over the past\n);
        $OUT .= qq(    $graphs_days days:</p>\n);
        $OUT .= qq(  <div class="graph"><a href="${graph_link}"><img class="graph"\n);
        $OUT .= qq(    src="${graph_link}" alt="The beforementioned graph for the ${q_tag} tag"\n);
        $OUT .= qq(    /></a></div>\n);
    }
    $OUT .= qq(<p>Emitted (non-overridden): $statistics{count}, );
    $OUT .= qq(overridden: $statistics{overrides}, );
    $OUT .= qq(total: $statistics{total}</p>);
}

  <p>
    The package names link to the relevant maintainer page and the
    corresponding report for the source package.  The links go to the full
    maintainer report page, which includes info and experimental tags and
    overridden tags, rather than the default page that shows only errors
    and warnings.
  </p> 
{
    # We get a list of tag data.  We create a separate paragraph for each
    # package name.
    my ($last, $last_pi, $tag, $has_nonoverridden);
    for my $info (sort { $a->{pkg_info}{package} cmp $b->{pkg_info}{package} } @tags) {
        my $pkg_info = $info->{pkg_info};
        if (!$last
            or "$pkg_info->{package} $pkg_info->{type} $pkg_info->{version}" ne "$last_pi->{package} $last_pi->{type} $last_pi->{version}") {
            if ($last) {
                my $overridden = $has_nonoverridden ? '' : qq{ <span class="type-O">overridden</span>};
                $OUT .= qq(  <h2 class="tag"><a href="${path_prefix}full/$last->{pkg_info}{xref}">);
                $OUT .= "$last_pi->{package} $last_pi->{version}</a> ($last_pi->{type}) (<em>$last_pi->{maintainer}</em>)$overridden</em></h2>\n";
                if ($tag) {
                    $OUT .= qq(  <ul class="tag">\n);
                    $OUT .= $tag;
                    $OUT .= "</ul>\n";
                } else {
                    $OUT .= qq(<br class="tag" />\n);
                }
            }
            $last = $info;
            $last_pi = $pkg_info;
            $tag = '';
            $has_nonoverridden = 0;
        }
        $has_nonoverridden = 1 if $info->{code} ne 'O';
        if ($info->{extra}) {
            $tag .= qq{    <li class="type-$info->{code}">};
            $tag .= qq{<span class="type-O">O</span> } if $info->{code} eq 'O';
            $tag .= $info->{extra};
            my @archs = sort keys %{ $info->{archs} };
            $tag .= " <tt>[" . join(', ', @archs) . "]</tt>" if @archs > 1;
            $tag .= "</li>";
        }
    }
    my $overridden = $has_nonoverridden ? '' : qq{ <span class="type-O">overridden</span>};
    $OUT .= qq(  <h2 class="tag"><a href="${path_prefix}full/$last->{pkg_info}{xref}">);
    $OUT .= "$last_pi->{package} $last_pi->{version}</a> ($last_pi->{type}) (<em>$last_pi->{maintainer}</em>)$overridden</h2>\n";
    if ($tag) {
        $OUT .= qq(  <ul class="tag">\n);
        $OUT .= $tag;
        $OUT .= "</ul>\n";
    } else {
        $OUT .= qq(<br class="tag" />\n);
    }
}
{ foot() }
