view makeBookeTunePages.sh @ 586:daa3b76bd11f

More abcfield.py updates and mark it Python 3. - Move title fixups into Python. - Move key display name expansion into Python. - Add Dottes-specific header continuation line format. None of the usual tools appears to support the official +: continuation.
author Jim Hague <jim.hague@acm.org>
date Mon, 31 Oct 2016 23:48:45 +0000
parents 760d0ae5acea
children afc031477784
line wrap: on
line source

#!/bin/bash
#
# Generate the LaTeX for the Booke tune pages (tunes.tex) and the index
# of first lines (firstlines.tex). These are generated into the build
# directory.
#
# All EPS and PDF tune graphics must be present already. Run
# makeGraphics.sh to make these.
#

if [ $# != 1 ]; then
    echo "Usage: makeBookeTunePages.sh <book dir name>"
    exit 1
fi

dir=`pwd`

booke=$dir/$1
builddir=$dir/build
graphicsdir=$dir/graphics/$1
tunesoutput=$builddir/tunes.tex
indexoutput=$builddir/firstlines.tex

mkdir -p $builddir

rm -f $tunesoutput $indexoutput

# Now, for each tune, make the tune graphic and add it, inside a
# centre section, so the document. Then add a TOC entry.
find $booke -name "*.abc" | sort |
    while read filename
    do
        name=`basename $filename .abc`
        title=`$dir/abcfield.py --field T --latex --display $filename`
        subtitle=`$dir/abcfield.py --index 2 --field T --latex --display $filename`
        composer=`$dir/abcfield.py --field C --latex $filename`

        changefile=`$dir/abcfield.py --field N --starts "Change:" $filename`
        changename=""
        changetitle=""
        if [ -n "$changefile" ]; then
            changename=`basename $changefile .abc`
            changetitle=`$dir/abcfield.py --field T --latex --display $booke/$changefile`
        fi

        credit=`$dir/abcfield.py --field N --starts "Credit:" $filename`
        echo -E "\showtune{$name}{$title}{$subtitle}{$composer}{$graphicsdir/$name}{$changename}{$changetitle}{$credit}" >> $tunesoutput

        echo -E "\showfirstline{$name}{$title}{$graphicsdir/firstline-$name}" >> $indexoutput
    done