md2pdf

pandoc wrapper for converting markdown to pdf
Index Commits Files Refs README
commit 6b1a46fa1c17392587fb0559b9a8ee2de459fd62
parent 579f5ac88ac35333fe9e4d4d4a113e7028e39fa3
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date:   Mon, 30 Sep 2024 11:41:06 -0300

add ability to pass custom style file

Diffstat:
Mmd2pdf | 17++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/md2pdf b/md2pdf
@@ -1,15 +1,26 @@
 #!/bin/sh
 
 usage() {
-    echo "md2pdf <inputfile>"
+    printf "md2pdf [OPTIONS] FILE.md\n"
+    printf "  -H, --style-file FILE.tex\tlatex template for pandoc\n"
 }
 
+md2pdf_path=$(dirname $(readlink -f $0))
+style_path=$md2pdf_path"/style.tex"
+if [ "$1" = "--style-file" ] || [ "$1" = "-H" ]; then
+    shift
+    style_path="$(readlink -f $1)"
+    shift
+fi
+
 [ -z "$1" ] && usage && exit 1
 
 filename=$(echo "$1" | sed 's/\.[^.]*$//')
 extension=$(echo "$1" | sed 's/^.*\.//')
-md2pdf_path=$(dirname $(readlink -f $0))
-style_path=$md2pdf_path"/style.tex"
+
+echo "* input file: \`$(realpath --relative-base=$HOME $1)\`"
+echo "* style file: \`$(realpath --relative-base=$HOME $style_path)\`"
+
 output="$filename.pdf"
 input_format="markdown+startnum+tex_math_dollars+implicit_figures"\
 "+grid_tables+backtick_code_blocks"