casile 0.14.4

The command line interface to the CaSILE toolkit, a book publishing workflow employing SILE and other wizardry
Documentation
#!@ZSH@
set -e

source "$CASILEDIR/lib/functions.zsh"

alias git="${GIT:-@GIT@}"
alias pandoc="${PANDOC:-@PANDOC@}"
alias rg="${RG:-@RG@}"

: ${bookid:=$1}
test -n bookid

require_pristine_project ${bookid}*

pandoc_args=(
	--lua-filter="$CASILEDIR/pandoc-filters/chapterid.lua"
)

# TODO: do we need turkish filename hacks back?
# $(SED) -n '/^#/{s/ı/i/g;p}' |

$CASILEDIR/scripts/list_related_files.zsh mds $bookid |
	xargs rg --files-without-match loadchapters.zsh |
	while read file; do
		basename $file | IFS='[-.]' read no _
		dirname $file | read dir
		rg -m1 '^#' $file | pandoc ${pandoc_args[@]} | read identifier
		[[ $identifier == nil ]] && continue
		git mv -k "$file" "$dir/$no-$identifier.md"
	done

commit "Normalize $bookid filenames based on heading ids"