#! /bin/bash 
# Last edited on 2025-05-03 18:04:21 by stolfi
set -e # Stop on first error.

# To be called after the EVT file specific of ${lang} and ${book} has been created.

lang="$1"; shift
book="$1"; shift

if [[ "/${lang}" == "/" ]]; then echo "** lang not specified" 1>&2; exit 1; fi
if [[ "/${book}" == "/" ]]; then echo "** book not specified" 1>&2; exit 1; fi

# Top folders for output data and output TeX tables of this note:
gen_dir="gen/${lang}/${book}"; mkdir -p ${gen_dir} 
tex_dir="tex/${lang}/${book}"; mkdir -p ${tex_dir}

if [[ "/${lang}" != "/voyn" ]]; then echo "** cannot handle language ${lang}" 1>&2; exit 1; fi

raw_evt="${gen_dir}/raw.evt"

used_sec_list="${gen_dir}/sections-used.tags"
echo "getting list of sections to analyze in ${lang}/${book} from ${used_sec_list} ..." 1>&2
sections=( `cat ${used_sec_list}` )

echo "making tables of ${lang}/${book} per section ..."
for sec in ${sections[@]} tot.1; do \
  ./make_lang_book_sec_tex_tables.sh ${lang} ${book} ${sec}
done
