Last active
November 13, 2020 21:53
-
-
Save otobrglez/457813072636fe4c271c7c559c69ee67 to your computer and use it in GitHub Desktop.
Markdown notes to PDFs with Pandoc (post2pdf.sh)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Author: Oto Brglez | |
# Mail: otobrglez@gmail.com | |
# Version: 0.0.2 | |
# LICENCE: MIT | |
# Install: | |
# - https://pandoc.org/ | |
# - https://github.com/Wandmalfarbe/pandoc-latex-template | |
# - https://www.overleaf.com/learn/latex/XeLaTeX | |
# - https://github.com/be5invis/Iosevka | |
function convert_save () { | |
source_file=$1 | |
base_source_name=$(basename $source_file) | |
echo "Convering: ${base_source_name}" | |
pandoc ${source_file} \ | |
-f markdown \ | |
-t pdf \ | |
-V papersize:a4 \ | |
-V linkcolor:blue \ | |
-V geometry:a4paper \ | |
-V geometry:margin=2cm \ | |
-V mainfont="Iosevka" \ | |
-V monofont="Iosevka Fixed" \ | |
-V classoption=oneside \ | |
--metadata=title:"$md" \ | |
--metadata=author:"Oto Brglez" \ | |
--metadata=lang:"en-US" \ | |
--template eisvogel \ | |
--pdf-engine=xelatex \ | |
-o ./pdfs/${base_source_name}.pdf; | |
echo "Conversion of ${base_source_name} completed." | |
} | |
export -f convert_save | |
if [ -z "$1" ]; then | |
ls *.md | xargs -n1 -I '{}' sh -c 'convert_save {}' | |
else | |
convert_save $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment