Skip to content

Instantly share code, notes, and snippets.

@otobrglez
Last active November 13, 2020 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save otobrglez/457813072636fe4c271c7c559c69ee67 to your computer and use it in GitHub Desktop.
Save otobrglez/457813072636fe4c271c7c559c69ee67 to your computer and use it in GitHub Desktop.
Markdown notes to PDFs with Pandoc (post2pdf.sh)
#!/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