12345678910111213141516171819202122232425262728293031323334 |
- #!/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/'
|