-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakehtml
executable file
·99 lines (78 loc) · 1.53 KB
/
makehtml
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
95
96
97
98
#!/bin/bash
if ! hash pandoc 2> /dev/null; then
echo "Pandoc does not appear to be installed"
exit 1
fi
NEWFILENAME=`echo -n "$1" | sed -e 's/.md$/.html/'`
CSSFILE=`mktemp`
CSSINCLUDE="$CSSFILE"
ISCYGWIN=1
cat > "$CSSFILE" << 'CSSEOF'
<style type="text/css">
body {
margin: 20px 60px;
font-family: sans-serif;
}
blockquote {
border-left: #004499 solid 6px;
padding-left: 0.5em;
margin-left: 2em;
}
h1, h2, h3, h4, h5, h6, h7 {
color: #004499;
}
li {
padding: 0.15em 0;
}
a {
color: #004499;
}
p code {
font-size: 1.21em;
}
div#TOC {
border: #004499 dotted 2px;
width: auto;
margin: 10px;
display: table;
padding: 10px 30px 10px 10px;
background-color: #eef8ff;
}
table {
margin: 10px;
border-collapse: collapse;
}
table thead tr {
border-bottom: #004499 solid 5px;
}
table thead tr th {
font-weight: heavy;
border: #004499 solid 1px;
padding: 5px 5px 2px 5px;
}
table tbody tr td {
border: #004499 solid 1px;
padding: 4px;
}
table tbody tr.odd {
background-color: #eef8ff;
}
</style>
CSSEOF
if [[ $(uname -s) == CYGWIN* ]]; then
CSSINCLUDE=`cygpath -w "$CSSFILE"`
ISCYGWIN=0
fi
pandoc "$1" --standalone \
--include-in-header="$CSSINCLUDE" --toc \
--highlight-style pygments \
--output="$NEWFILENAME"
PANDOCSUCCESS=$?
rm $CSSFILE
if [ $PANDOCSUCCESS ]; then
if [ $ISCYGWIN ]; then
cygstart "$NEWFILENAME"
elif [[ $(hash xdg-open 2> /dev/null) && -z $DISPLAY ]]; then
xdg-open "$NEWFILENAME"
fi
fi