forked from LearnPrologNow/lpn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_generate_html
executable file
·97 lines (88 loc) · 1.97 KB
/
_generate_html
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
#!/bin/bash
INDIR=text
OUTDIR="`pwd`/www/html/"
SCRIPTSDIR="`pwd`/scripts"
init()
{
echo ${OUTDIR}
mkdir -p ${OUTDIR}
}
convertpix()
{
for p in ${INDIR}/*.eps; do
echo "Converting eps file $p"
convert -density 150 $p -flatten $p.png
mv $p.png ${OUTDIR}
done
pushd .
cd ${INDIR}
for p in chap*pspic*.tex; do
latex $p
done
for p in chap*pspic*.dvi; do
dvips -E $p
done
popd
for p in ${INDIR}/chap*pspic*.ps; do
echo "Converting ps file $p"
convert -density 150 $p -flatten $p.png
mv $p.png ${OUTDIR}
done
}
convertlatex()
{
pushd .
cd ${INDIR}
cp LPNmacros.tex LPNtempmacros1.tex
echo "\renewcommand{\Thischapter}[2]{\setcounter{length}{#1}#2}" > LPNtempmacros2.tex
cat LPNtempmacros1.tex LPNtempmacros2.tex > LPNmacros.tex
cat lpn.tex | grep -v kcp | grep -v bbheadings | grep -v bbanswers | grep -v appendix > lpn-html.tex
htlatex lpn-html.tex "lpn-html,xhtml,3,info" "" "-d${OUTDIR}"
cp LPNtempmacros1.tex LPNmacros.tex
rm -f LPNtempmacros?.tex
popd
}
adjusthtml()
{
pushd .
cd ${OUTDIR}
for HTML in `ls ${OUTDIR}*.html`; do
echo "Adjusting: ${HTML}"
cat ${HTML} | ${SCRIPTSDIR}/lpn_get_body.py > temp.html
cat temp.html \
| tr "\n" " " \
| tr -s " " \
| sed "s/</\n</g" \
| sed 's/<a href="/<a href="lpnpage.php?pagetype=html\&pageid=/g' \
| sed 's/\.html.*"/"/' \
| sed 's/<img src="/<img src="html\//' \
| sed 's/Exercise/<strong>Exercise<\/strong>/g' \
> ${HTML}
rm -f temp.html
done
# Generating a new online.php file
cat lpn-html.html \
| tr "\n" " " \
| sed 's/<span/@<span/g' \
| tr "@" "\n" \
| grep '"chapterToc' \
| grep htmlch \
| sed 's/ //' \
| sed 's/chapterToc">/chapterToc">Chapter/' > ../online.php
popd
}
finit()
{
pushd .
cd ${INDIR}
rm -f lpn-html*.html
rm -f *.aux
rm -f *.dvi
popd
}
init
convertpix
convertlatex
adjusthtml
finit
exit 0