md2tex.sh 729 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. # This script combines all markdown files to a LaTeX file.
  3. # Check if pandoc is installed
  4. if ! [ -x "$(command -v pandoc)" ]; then
  5. echo 'Error: pandoc is not installed.' >&2
  6. exit 1
  7. fi
  8. # Check if pandoc-citeproc is installed
  9. if ! [ -x "$(command -v pandoc-citeproc)" ]; then
  10. echo 'Error: pandoc-citeproc is not installed.' >&2
  11. exit 1
  12. fi
  13. FILES=`find . -maxdepth 1 -type f -regex ".*[0-9]+_.*\.md" -print | sort`
  14. echo "Converting $FILES to LaTeX..."
  15. pandoc -s -S --bibliography=references/references.bib --filter pandoc-citeproc --latex-engine=xelatex -o "out/combined.md.tex" $FILES
  16. echo "Done."
  17. # convert latex to pdf
  18. echo "Converting LaTeX to PDF..."
  19. xelatex -output-directory=out main.tex
  20. echo "Done."