Fix zlib usage with TNG
[alexxy/gromacs.git] / docs / manual / mkmdp
1 #!/bin/bash
2
3 if [[ ! -d $1 ]]; then
4   echo "Error: provide the GROMACS html directory as first argument."
5   exit
6 fi
7
8 GMXHTMLDIR=$1
9
10 dir=${PWD}
11
12 TEXDIR=.
13 MANDIR=online
14 HTML=$GMXHTMLDIR
15 HTMLOL=$HTML/$MANDIR
16 HTMLMDPOPT=$HTMLOL/mdp_opt.html
17 TEXMDPOPT=$TEXDIR/mdp_opt.tex
18
19 echo "Will convert $HTMLMDPOPT (html format)"
20 echo "to $TEXMDPOPT (latex format)"
21
22 echo -n "parsing."
23 sed \
24 -e 's/<[aA] [^>]*>//g' \
25 -e 's/<\/[aA]>//g' \
26 -e 's/<[iI][mM][gG] [^>]*>//g' \
27 -e 's/<[pP]>//g' \
28 -e 's/<\/[pP]>//g' \
29 -e 's/&[nN][bB][sS][pP];/~/g' \
30 -e 's/<[hH][rR]>//g' \
31 $HTMLMDPOPT > temp1
32
33 echo -n "."
34 awk '{
35   if (NF) {
36     if ( ($1 == "<P>") || ($1 == "<p>") || ($1 == "<BR>") || ($1 == "<br>") )
37       print ""
38     else
39       print $0
40     }
41   }' temp1 > temp2
42 echo -n "."
43 sed \
44 -e 's/&gt;=/$\\geq$/g;s/&ge;/$\\geq$/g' \
45 -e 's/&gt;/$\>$/g' \
46 -e 's/&lt;=/$\\leq$/g;s/&le;/$\\leq$/g' \
47 -e 's/&lt;/$\<$/g' \
48 -e 's/_/_/g' \
49 -e 's/%/\\%/g' \
50 -e 's/&/\\&/g' \
51 -e 's/<sup>\([^<]*\)<\/sup>/$^{\1}$/g' \
52 -e 's/<sub>\([^<]*\)<\/sub>/$_{\1}$/g' \
53 -e 's/<[tT][tT]>\([^<]*\)<\/[tT][tT]>/{\\tt \1}/g' \
54 -e 's/<[pP][rR][eE]>\([^<]*\)<\/[pP][rR][eE]>/\\\\{\\tt\1}\\\\/g' \
55 -e 's/<\!--Idx-->\([^>]*\)<\!--EIdx-->/\\normindex{\1}/g' \
56 -e 's/<\!--QuietIdx-->\([^>]*\)<\!--EQuietIdx-->/\\index{\1}/g' \
57 -e 's/<[hH]1>\([^<]*\)<\/[hH]1>/\\section{\1}/g' \
58 -e 's/<[hH]3>\([^<]*\)<\/[hH]3>/\\subsection{\1}/g' \
59 temp2 > temp3
60
61 echo -n "."
62 sed \
63 -e 's/<[uU][lL]>/\\begin{itemize}/g' \
64 -e 's/<\/[uU][lL]>/\\end{itemize}/g' \
65 -e 's/<[lL][iI]>/\\item /g' \
66 -e 's/<[dD][lL] [cC][oO][^>]*>/\\vspace{-2ex}\\begin{description}[font=\\ttfamily]/g' \
67 -e 's/<[dD][lL][^>]*>/\\begin{description}[font=\\ttfamily]/g' \
68 -e 's/<\/[dD][lL]>/\\end{description}/g' \
69 -e 's/<[dD][tT]><[bB]>\(.*\)<\/[bB]>\(.*\)<\/[dD][tT]>/\\item[\1] \2\\hfill\\\\/g' \
70 -e 's/<[dD][tT]>\([^<]*\)<\/[dD][tT]>/\\item[\1]\\hfill\\\\/g' \
71 -e 's/<[bB]>\([^<]*\)<\/[bB]>/{\\tt \1}/g' \
72 -e 's/<[iI]>\([^<]*\)<\/[iI]>/{\\em \1}/g' \
73 -e 's/<[dD][dD]>//g' \
74 -e 's/<\/[dD][dD]>//g' \
75 -e 's/<\/[dD][tT]>//g' \
76 -e 's/ \(\[[^]]*\]\)\]/ {\1}\]/g' \
77 -e 's/\$lt\$/$<$/g' \
78 -e 's/\$gt\$/$>$/g' \
79 -e 's/e\.g\./{\\eg}/g' \
80 -e 's/i\.e\./{\\ie}/g' \
81 temp3 > temp4
82
83 echo -n "."
84 awk 'BEGIN { printf("\\label{sec:mdpopt}\n"); }\
85 {\
86   if ( index($0,"subsection") ) {\
87     if ( index($0,"General") ) {\
88       output=1;\
89     } else if ( index($0,"Index") )\
90       output=0;\
91   }\
92   if (output) print;\
93 }' temp4 > $TEXMDPOPT
94
95 echo "."
96
97 rm temp1 temp2 temp3 temp4
98
99 #last line
100 exit