File tree Expand file tree Collapse file tree 1 file changed +34
-8
lines changed Expand file tree Collapse file tree 1 file changed +34
-8
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
# Script based on https://learnbyexample.github.io/tutorial/ebook-generation/customizing-pandoc/
3
+
4
+ Help ()
5
+ {
6
+ # Display Help
7
+ echo " Generate guide PDF from a master MarkDown file."
8
+ echo
9
+ echo " Syntax: md2pdf.sh ./Build/<mastermarkdown> <output.pdf>"
10
+ echo
11
+ exit
12
+ }
13
+
14
+ while getopts " :h" option; do
15
+ case $option in
16
+ h | * ) # display Help
17
+ Help
18
+ exit ;;
19
+ esac
20
+ done
21
+
22
+ if [ -z " $1 " ]
23
+ then
24
+ Help
25
+ exit
26
+ fi
27
+
3
28
SCRIPT=$( readlink -f " $0 " )
4
29
SCRIPTPATH=$( dirname " $SCRIPT " )
5
-
6
- pandoc " $tfl " \
30
+ echo -e " \e[1;32m Running Pandoc to generate the LaTex file. \e[0m "
31
+ pandoc " $1 " \
7
32
-f gfm \
8
33
--toc \
9
34
--listings \
@@ -20,15 +45,16 @@ pandoc "$tfl" \
20
45
-V mainfont=" DejaVu Serif" \
21
46
-V monofont=" DejaVu Sans Mono" \
22
47
--pdf-engine=xelatex \
23
- -o temp.tex
48
+ -o /tmp/ temp.tex
24
49
50
+ echo -e " \e[1;32m Running Perl to format the output. \e[0m"
25
51
fn=" ${2% .* } "
26
52
27
- perl -0777 -pe ' s/begin\{document\}\n\n\K(.*?^\}$)(.+?)\n/$2\n\\thispagestyle{empty}\n\n$1\n/ms' temp.tex > ${fn} .tex
28
-
29
- xelatex ${SCRIPTPATH} /${fn} .tex & > /dev/null
30
- xelatex ${SCRIPTPATH} /${fn} .tex & > /dev/null
53
+ perl -0777 -pe ' s/begin\{document\}\n\n\K(.*?^\}$)(.+?)\n/$2\n\\thispagestyle{empty}\n\n$1\n/ms' /tmp/temp.tex > ${SCRIPTPATH} /${fn} .tex
31
54
32
- rm temp.tex " $fn " .{tex,toc,aux,log}
55
+ echo -e " \e[1;32m Generating PDF. \e[0m"
56
+ xelatex ${SCRIPTPATH} /${fn} .tex > ${SCRIPTPATH} /pdfgen.log
33
57
58
+ echo -e " \e[1;32m Cleanning temp files. \e[0m"
59
+ rm /tmp/temp.tex " $fn " .{tex,toc,aux,log}
34
60
You can’t perform that action at this time.
0 commit comments