def modline(line)
  if line=~/a href=(.*)>(.*)<\/a/
    label = $1
    name = $2
    label.gsub!(/\"/,"")
    puts "<li><OBJECT type=\"text/sitemap\"><param name=\"Name\" value=\"#{name}\">"
    puts "<param name=\"Local\" value=\"qcadhelp.html#{label}\">"
    puts "</OBJECT>"
  elsif line=~/<li>(.*)/
    name = $1
    puts "<li><OBJECT type=\"text/sitemap\"><param name=\"Name\" value=\"#{name}\">"
    puts "</OBJECT>"
  else
    print line
  end
end

def putheader
print <<EOS
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
<!-- Sitemap 1.0 -->
</HEAD><BODY>
EOS
end

def putfooter
  puts "</BODY></HTML>"
end

putheader

flag = false
while line=gets
  if line=~/label-1/
    flag = true
    next
  elsif line=~/h2/
    putfooter
    exit
  end
  modline(line) if flag
end

