#!/bin/bash # converts aqoaba markdown into tex # TODO # - [ ] formatting scripture https://tex.stackexchange.com/a/652451/264579 # - [ ] do I even need mutliple verse environments? USAGE="""USAGE: $(basename $0) markdown-file""" if [ $# -ne 1 ] ; then echo "$USAGE" && exit 1; fi INFILE=$1 # remove any suffix https://stackoverflow.com/a/36341390 BASENAME=$(basename "${INFILE%.*}") KEEP_TMP_FILES=0 sed \ 's/^$/\\end{verse}\ \ \\begin{verse}/' \ ${INFILE} \ > ${BASENAME}.tmp1 # remove first end{verse} https://unix.stackexchange.com/a/335450 cat \ ${BASENAME}.tmp1 \ | awk -v c=1 '/end{verse}/ && i++ < c {next};1' \ > ${BASENAME}.tmp2 # remove last begin{verse} https://unix.stackexchange.com/a/335450 tac \ ${BASENAME}.tmp2 \ | awk -v c=1 '/begin{verse}/ && i++ < c {next};1' \ | tac \ > ${BASENAME}.tmp3 # translate from ako.aba.md to latex pandoc \ -f markdown \ ${BASENAME}.tmp3 \ -t latex \ -o ${BASENAME}.tmp4 # --wrap=preserve \ #sed \ # -e "s/subsection/attrib/" \ # -e "s/section/poemtitle/" \ # ${BASENAME}.tmp4 \ # > ${BASENAME}.tex sed \ -e "s/subsection/attrib/" \ -e "s/section/poemtitle/" \ ${BASENAME}.tmp4 if ! [[ $KEEP_TMP_FILES -gt 0 ]] then rm *tmp* fi