#!/bin/sh
# post-process sgmls output to make canonical version or tag listing
def='("format","normal","full","yes","direct","unspecified","org","uniform",
      "part","n","sample","complete","place","unspecified","targorder","u",
      "anchored","yes",
      "gram","yes","rel","notrel","vg","notvg","coord","notcoord",
      "fvs","notfvs")'
# blb='("/./","/^<div/","m|^</|","/^<p[ >]/","/^<div/","/./")'
if [ "$1" = "-to" ]
 then
  tof='@tags_only=("type","id");'
  shift
 else
  blb='@blank_line_between=("/./","/^<div.?\$/","m|^</|","/^<(p|table|list|head|tail|trailer|item)\$/");'
fi
if [ "$1" = "-kib" ]
 then
  kib='$keep_blanks=1;'
  shift
fi
if [ "$1" = "-kent" ]
 then
  ent='@entities=();'
  shift
 else
  ent='@entities=("s|&([a-zA-Z])|&amp;\$1|g","s/<([a-zA-Z])/&lab;\$1/g",
                  "s/&@/&/g");'
fi
ato='("div0","type","div1","type","div2","type","div3","type","div4","type","head","type","p","type","corr","sic;rend")'
perl $ECI_ROOT/src/perl/post.pl "$ent\
				    %defaults=$def;\
				    \$empty='(omit|pb|lb|milestone|rule)';\
				    $blb\
				    $tof\
				    $kib\
				    %att_order=$ato"
