
# ----------------- Using taggrep ----------------- #

%FirstTime = (
    'meta'  => 1,
    'title' => 1,
    'link'  => 1,
    'h1'    => 1,
    'h2'    => 1,
    'h3'    => 1,
    'h4'    => 1,
    'h5'    => 1,
    'h6'    => 1,
);

@FullResult = undef;

sub BuildArray {
  use strict;
  my ($arg,@files) = @_;
  my(@result,@dirlist,$dir,$cmd,$file);
  my $type = $arg; 
  $type =~ s/.* //;

  if ($::FirstTime{$type}) {
    foreach $file (@files) {
      ($dir = $file) =~ s/^(.*)\/.*$/$1/;
      push(@dirlist,$dir) unless grep(/^$dir$/, @dirlist);
    }
    foreach $dir (@dirlist) {
      $cmd = $::TagGrepCmd." ".$arg." ".$dir."/\*.html"." ".$dir."/\*.htm"." ".$dir."/\*.shtml";
      push(@::FullResult,`$cmd`);
    }
    $::FirstTime{$type} = 0;
  }

  @result = grep(/<$type/i, @::FullResult);
  return @result;
}


sub GetArray {
  use strict;
  my($file,@array) = @_;
  my(@list,@result,$f,$n,$t);

  @list = grep /^$file:/, @array;

# The list is of the form filename:line_number:text
# Return just the text part for matching files

  foreach (@list) {
    ($f,$n,$t) = split(/\s*:\s*/,$_,3);
    push(@result,$t);
  }
  
  return @result;
}
