1
0
Fork 0
forked from avana/cryptrdie
cryptrdie/script/convert.sh
2014-06-18 12:36:32 +02:00

34 lines
647 B
Bash
Executable file

#!/bin/bash
#
# from wikifile to latex file
# e.g.
# bash convert.sh <filename>
#
input=$1
output=${input}.tex
err(){
echo $1
exit
}
[ -z ${input} ] && err "no input file"
[ ! -f ${input} ] && err "no valid input file, check your path"
pandocbin=`which pandoc`
[ -z "${pandocbin}" ] && err "no pandoc binary"
echo "pandoc..." > /dev/stderr
${pandocbin} ${input} -o ${output}
echo "pleas check ${output}" > /dev/stderr
cat ${output} | sed -e 's/h5\.\ \(.*\)/\\subsubsection{\1}/' -e 's/h4\.\ \(.*\)/\\subsection{\1}/' -e 's/h3\.\ \(.*\)/\\section{\1}/' -e 's/h2\.\ \(.*\)/\\chapter{\1}/' -e 's/h1\./\%h1\./' -e 's/h0/\%h0/'