#! /bin/csh -f
# Last edited on 1999-01-06 15:45:25 by stolfi

set usage = "$0 [ -title TITLE ] < INFILE.hix > INDEX.html"

# Each line of INFILE represents one occurrence of some string 
# in the text, in the format
# 
#   STRING HNUM PATT
#   1      2    3   
#
# See Note-037.txt for explanation of the fields.

set title = "Concordance index"

while ( ( $#argv >= 1) && ( "x$1" =~ x-* ) ) 
  if ( ( $#argv >= 2) && ( "x$1" == "x-title" ) ) then
    set title = "$2";
    shift; shift;
  else
    echo "bad option $1"; echo "usage: ${usage}"; exit 1
  endif
end

# Output the HTML file: 

set dt = "`date +'%Y-%m-%d %H:%M:%S'`"

cat <<EOF
<html>
<head>
  <title>${title}</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0022ff" vlink="#aa00aa">
<small><p>
Generated by J. Stolfi on ${dt}
</p></small>

<b><tt><pre>

<h1>${title}</h1>

EOF

gawk \
  ' /./ { \
      str = $1; hpg = $2; pat = $3; \
      gsub(/[.]/, " ", str); \
      printf "<a href=\"%s.html#%s\">%s</a>\n", hpg, pat, str; \
    } \
  ' 
  
cat <<EOF

</pre></tt></b>
</body>
</html>
EOF