-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile
executable file
·95 lines (79 loc) · 1.61 KB
/
compile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
# Converts a MarkDown formatted docment to HTML or optionally PDF.
# Usage:
# compileMarkdown mySource.md
# compileMarkdown mySource.md html
# compileMarkdown mySource.md pdf
set -e
. "$HOME/bin/_shared"
#file_pp_md=$1
file_pp_md="talk.pp.md"
base=`dirname $file_pp_md`/`basename $file_pp_md | sed -e 's/\.pp\.m.*//'`
file_md="${base}.md"
target_format=html
if [ "$1" != "" ]
then
target_format=$1
fi
table_of_contents="true"
if [ "$2" = "-p" ]
then
table_of_contents="false"
fi
if [ 1 -eq 0 ]
# TODO
then
while ffff
do
case "${_action}" in
-p)
table_of_contents="false"
;;
*)
echo "Unknonwn action: '${@}'"
exit 1
esac
shift
done
fi
if [ "$target_format" != "html" -a "$target_format" != "pdf" ]
then
echoerr ""
exit 1
fi
target="${base}.$target_format"
echo "\nPP -- Pre-Processing (.pp.md -> .md) ..."
pp "$file_pp_md" > "$file_md"
# Basic Markdown:
markdown_flavour=markdown
# GitHub flavoured Markdown:
#markdown_flavour=gfm
common_options="--standalone"
if [ "$table_of_contents" = "true" ]
then
common_options="$common_options --toc"
fi
echo "\nMarkdown compiling into $target_format ..."
if [ "$target_format" = "html" ]
then
open_app="firefox"
pandoc \
$common_options \
-f $markdown_flavour \
-t $target_format \
--css "$HOME/res/pandoc.css" \
"$file_md" \
> "$target"
elif [ "$target_format" = "pdf" ]
then
open_app="evince"
pandoc \
$common_options \
-f $markdown_flavour \
--css "$HOME/res/pandoc.css" \
-o "$target" \
"$file_md"
fi
target_path=`readlink -f $target`
echo "$target written; you might want to open it with:"
echo "$open_app \"$target_path\" &"