md2verse.sh write to stdout

This commit is contained in:
uni@bor.mac 2024-10-01 15:51:29 +02:00
parent 4d9e23a11f
commit e43bad85b5

View File

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
# converts akoaba markdown into tex # converts aqoaba markdown into tex
# TODO # TODO
# - formatting scripture https://tex.stackexchange.com/a/652451/264579 # - [ ] formatting scripture https://tex.stackexchange.com/a/652451/264579
# - do I even need mutliple verse environments? # - [ ] do I even need mutliple verse environments?
USAGE="""USAGE: USAGE="""USAGE:
$(basename $0) markdown-file""" $(basename $0) markdown-file"""
if [ $# -ne 1 ] ; then echo "$USAGE" && exit 1; fi if [ $# -ne 1 ] ; then echo "$USAGE" && exit 1; fi
@ -11,29 +11,6 @@ INFILE=$1
BASENAME=$(basename "${INFILE%.*}") BASENAME=$(basename "${INFILE%.*}")
KEEP_TMP_FILES=0 KEEP_TMP_FILES=0
###############
# OLD VERSION #
###############
## translate from pandoc md to latex
#pandoc \
# -f markdown \
# ${bname}.md \
# -t latex \
# -o ${bname}.tmp1
## repurpose headings and verbatim
#sed \
# -e "s/subsection/attrib/" \
# -e "s/section/poemtitle/" \
# -e "s/verbatim/verse/" \
# ${bname}.tmp1 \
# > ${bname}.tex
## insert verse into empty lines
###################
# SECOND VERSION #
###################
sed \ sed \
's/^$/\\end{verse}\ 's/^$/\\end{verse}\
\ \
@ -58,11 +35,15 @@ pandoc \
-t latex \ -t latex \
-o ${BASENAME}.tmp4 -o ${BASENAME}.tmp4
# --wrap=preserve \ # --wrap=preserve \
#sed \
# -e "s/subsection/attrib/" \
# -e "s/section/poemtitle/" \
# ${BASENAME}.tmp4 \
# > ${BASENAME}.tex
sed \ sed \
-e "s/subsection/attrib/" \ -e "s/subsection/attrib/" \
-e "s/section/poemtitle/" \ -e "s/section/poemtitle/" \
${BASENAME}.tmp4 \ ${BASENAME}.tmp4
> ${BASENAME}.tex
if ! [[ $KEEP_TMP_FILES -gt 0 ]] if ! [[ $KEEP_TMP_FILES -gt 0 ]]
then then