add md2verses.h
This commit is contained in:
parent
782b455830
commit
4d9e23a11f
70
md2verse.sh
Executable file
70
md2verse.sh
Executable file
@ -0,0 +1,70 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# converts akoaba 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
|
||||||
|
|
||||||
|
|
||||||
|
###############
|
||||||
|
# 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 \
|
||||||
|
'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
|
||||||
|
|
||||||
|
if ! [[ $KEEP_TMP_FILES -gt 0 ]]
|
||||||
|
then
|
||||||
|
rm *tmp*
|
||||||
|
fi
|
14
testfiles/verse.md
Normal file
14
testfiles/verse.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Maior é deus
|
||||||
|
|
||||||
|
Iê!
|
||||||
|
|
||||||
|
Maior é Deus (bis)
|
||||||
|
Pequeno sou eu
|
||||||
|
O que tenho, foi Deus que me deu
|
||||||
|
Tudo tenho, foi Deus que me deu
|
||||||
|
Na roda da Capoeira, ha! ha!
|
||||||
|
Grande pequeno sou eu
|
||||||
|
|
||||||
|
Camarada ! ...
|
||||||
|
|
||||||
|
## Mestre Pastinha
|
Loading…
Reference in New Issue
Block a user