This repository has been archived by the owner on Aug 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
mkmdp
executable file
·100 lines (88 loc) · 2.42 KB
/
mkmdp
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
99
100
#!/bin/bash
if [[ ! -d $1 ]]; then
echo "Error: provide the GROMACS html directory as first argument."
exit
fi
GMXHTMLDIR=$1
dir=${PWD}
TEXDIR=.
MANDIR=online
HTML=$GMXHTMLDIR
HTMLOL=$HTML/$MANDIR
HTMLMDPOPT=$HTMLOL/mdp_opt.html
TEXMDPOPT=$TEXDIR/mdp_opt.tex
echo "Will convert $HTMLMDPOPT (html format)"
echo "to $TEXMDPOPT (latex format)"
echo -n "parsing."
sed \
-e 's/<[aA] [^>]*>//g' \
-e 's/<\/[aA]>//g' \
-e 's/<[iI][mM][gG] [^>]*>//g' \
-e 's/<[pP]>//g' \
-e 's/<\/[pP]>//g' \
-e 's/&[nN][bB][sS][pP];/~/g' \
-e 's/<[hH][rR]>//g' \
$HTMLMDPOPT > temp1
echo -n "."
awk '{
if (NF) {
if ( ($1 == "<P>") || ($1 == "<p>") || ($1 == "<BR>") || ($1 == "<br>") )
print ""
else
print $0
}
}' temp1 > temp2
echo -n "."
sed \
-e 's/>=/$\\geq$/g;s/≥/$\\geq$/g' \
-e 's/>/$\>$/g' \
-e 's/<=/$\\leq$/g;s/≤/$\\leq$/g' \
-e 's/</$\<$/g' \
-e 's/_/_/g' \
-e 's/%/\\%/g' \
-e 's/&/\\&/g' \
-e 's/<sup>\([^<]*\)<\/sup>/$^{\1}$/g' \
-e 's/<sub>\([^<]*\)<\/sub>/$_{\1}$/g' \
-e 's/<[tT][tT]>\([^<]*\)<\/[tT][tT]>/{\\tt \1}/g' \
-e 's/<[pP][rR][eE]>\([^<]*\)<\/[pP][rR][eE]>/\\\\{\\tt\1}\\\\/g' \
-e 's/<\!--Idx-->\([^>]*\)<\!--EIdx-->/\\normindex{\1}/g' \
-e 's/<\!--QuietIdx-->\([^>]*\)<\!--EQuietIdx-->/\\index{\1}/g' \
-e 's/<[hH]1>\([^<]*\)<\/[hH]1>/\\section{\1}/g' \
-e 's/<[hH]3>\([^<]*\)<\/[hH]3>/\\subsection{\1}/g' \
temp2 > temp3
echo -n "."
sed \
-e 's/<[uU][lL]>/\\begin{itemize}/g' \
-e 's/<\/[uU][lL]>/\\end{itemize}/g' \
-e 's/<[lL][iI]>/\\item /g' \
-e 's/<[dD][lL] [cC][oO][^>]*>/\\vspace{-2ex}\\begin{description}[font=\\ttfamily]/g' \
-e 's/<[dD][lL][^>]*>/\\begin{description}[font=\\ttfamily]/g' \
-e 's/<\/[dD][lL]>/\\end{description}/g' \
-e 's/<[dD][tT]><[bB]>\(.*\)<\/[bB]>\(.*\)<\/[dD][tT]>/\\item[\1] \2\\hfill\\\\/g' \
-e 's/<[dD][tT]>\([^<]*\)<\/[dD][tT]>/\\item[\1]\\hfill\\\\/g' \
-e 's/<[bB]>\([^<]*\)<\/[bB]>/{\\tt \1}/g' \
-e 's/<[iI]>\([^<]*\)<\/[iI]>/{\\em \1}/g' \
-e 's/<[dD][dD]>//g' \
-e 's/<\/[dD][dD]>//g' \
-e 's/<\/[dD][tT]>//g' \
-e 's/ \(\[[^]]*\]\)\]/ {\1}\]/g' \
-e 's/\$lt\$/$<$/g' \
-e 's/\$gt\$/$>$/g' \
-e 's/e\.g\./{\\eg}/g' \
-e 's/i\.e\./{\\ie}/g' \
temp3 > temp4
echo -n "."
awk 'BEGIN { printf("\\label{sec:mdpopt}\n"); }\
{\
if ( index($0,"subsection") ) {\
if ( index($0,"General") ) {\
output=1;\
} else if ( index($0,"Index") )\
output=0;\
}\
if (output) print;\
}' temp4 > $TEXMDPOPT
echo "."
rm temp1 temp2 temp3 temp4
#last line
exit