-
Notifications
You must be signed in to change notification settings - Fork 2
/
get_long_html_outline.sh
executable file
·69 lines (61 loc) · 1.45 KB
/
get_long_html_outline.sh
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
#!/bin/bash
COURSE=$1
INPUT="$COURSE".tex
TOC="$COURSE".toc
OUTLINE="$COURSE"-long-outline.html
COURSE=$COURSE
VERSION=$(grep '\\newcommand{\\version}' $INPUT \
| sed -e s/'\\newcommand{\\version}{'//g | sed -e s/'}'//g) \
TITLE="$(grep 'coursetitle' $INPUT \
| sed -e s/'\\newcommand{\\coursetitle}{'//g | sed -e s/'}'//g)" \
cat <<EOF > $OUTLINE
<HTML>
<HEAD>
<TITLE>
$COURSE $TITLE
</TITLE>
</HEAD>
<BODY>
<H1>$COURSE $TITLE</H1>
<OL>
EOF
appendixstart="$(grep -n Appendices $TOC)"
appendixstart="$(echo $appendixstart | sed 's/:.*//')"
lastline=$(($appendixstart-1))
head -n $lastline $TOC | \
sed \
-e s/'\\contentsline'//g \
-e s/'{\\numberline '//g \
-e s/'{chapter}'/'<\/UL><LI>'/g \
-e s/'{chapter.*}'/'<UL>'/g \
-e s/'\\_'/_/g \
| sed \
-e s/}{[0-9]}/'<\/LI>'/g \
-e s/}{[0-9][0-9]}/'<\/LI>'/g \
-e s/}{[0-9][0-9][0-9]}/'<\/LI>'/g \
-e s/{section}/'<LI>'/g \
| sed -e s/'\\textbf {'/'<B>'/g \
-e s/'\\texttt {'/'<B>'/g \
| sed \
-e s/{[0-9].[0-9]}//g \
-e s/{[0-9][0-9].[0-9]}//g \
-e s/{[0-9].[0-9][0-9]}//g \
-e s/{[0-9][0-9].[0-9][0-9]}//g \
-e s/{section.*}//g \
-e s/{..}//g \
-e s/{.}//g \
| sed \
-e s/'}'/'<\/B>'/g \
| sed \
-e s/{....}//g \
| sed \
-e 0,/'<\/UL>'/s/'<\/UL>'// \
| grep -vi ppendi \
| grep -v 'select@language' \
>> $OUTLINE
cat <<EOF >> $OUTLINE
</UL></OL>
</BODY>
</HTML>
EOF
echo I made: "$OUTLINE"