#! /bin/bash
# Last edited on 2025-05-01 23:11:28 by stolfi

# Creates a list of sections "sections.tags" with the section tags ("hea.1", "cos.2", etc)
# for the specified ${lang} and ${book} and a version "sections-ok.tags" that excludes
# the "unk.*" sections. Neither list includes the "tot.1" pseudo-section.
# The lists are placed in "dat/${lang}/${book}/"

lang="$1"; next
book="$1"; next
JUNK


out_dir="dat/${lang}/${book}"

sec_list_file="${out_dir}/sections.tags"
echo "creating ${sec_list_file} from 

# Create list of sections for this book:
dat/${sec_list_file}: dat/${out_dir} ${MAKERULES}
	echo "${SECTIONS}" \
          | tr ' ' '\012' \
          > dat/${sec_list_file}
sec_ok_list_file="${out_dir}/sections-ok.tags"


# Create list of "OK" sections for this book:
dat/${sec_ok_list_file}: dat/${sec_list_file}
	cat dat/${sec_list_file} \
          | egrep -v '^(unk|xxx)' \
          > dat/${sec_ok_list_file}
