Skip to content

Commit

Permalink
feat(pandoc): add utils/script for markdown to pdf conversion
Browse files Browse the repository at this point in the history
includes templates
  • Loading branch information
PrashanthaTP committed Nov 4, 2021
1 parent 7540b0a commit fc61ff9
Show file tree
Hide file tree
Showing 11 changed files with 1,725 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .config/utils/pandoc/md2pdf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#! /bin/sh
if [ "$1" == "-h" ] ; then
echo "Usage: `basename $0` [input_file] [out_dir] [-h]"
fi

if [ -z "$1" ]
then
echo "No input file specified."
exit 0
fi

if [ -z "$2" ];then
out_dir=pdf
else
out_dir=$2
fi
echo "Creating output dir if not exists : $out_dir"
mkdir -p "$out_dir"
echo "======== Markdown to PDF ================"
filename_full=$(basename -- "$1")
extension="${filename_full##*.}"
filename="${filename_full%.*}"
out_file=$out_dir/${filename}".pdf"
data_dir="$HOME/.config/utils/pandoc"
header_file="$data_dir/templates/head.tex"
user_metadata_file="$(dirname \"$1\")/metadata.yml"
metadata_file="~/.config/utils/templates/metadata.yml"
[ -f "$user_metadata_file" ] && metadata_file="$user_metadata_file"
echo "Source file": $filename_full
echo "Target file": $out_file
echo "Metadata file": $metadata_file

pandoc -N -s \
--data-dir="$data_dir"\
--template=eisvogel.tex \
-H "$header_file" \
--listings $1 \
--toc --toc-depth=4 \
--metadata-file "$metadata_file" \
-o $out_file


echo "========================================="
Binary file added .config/utils/pandoc/templates/Document1.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions .config/utils/pandoc/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Dev Utils

## Markdown to Pdf

# LICENSE :
* [https://github.com/Wandmalfarbe/pandoc-latex-template/LICENSE](https://github.com/Wandmalfarbe/pandoc-latex-template/blob/6baf692c89a5be30a44e4dd0137d8a07bd0a114c/LICENSE)
* Jdhao's [blog](https://jdhao.github.io/2019/05/30/markdown2pdf_pandoc/] : [Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)](https://creativecommons.org/licenses/by-nc-nd/4.0/)
Binary file added .config/utils/pandoc/templates/background.pdf
Binary file not shown.
Binary file added .config/utils/pandoc/templates/background1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .config/utils/pandoc/templates/background1.pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit fc61ff9

Please sign in to comment.