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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
#!/bin/sh
#cut at given keyword
keyword()
{
# I changed "0" to "\$" because my sed
# doesn't want to understand "0".
# -- Zoltan
sed "1,/^%$1/ d;/^%/,\$ d"
}
menus()
{
# I changed "0" to "\$" because my sed
# doesn't want to understand "0".
# -- Zoltan
sed "1,/^%menus/ d;/^%endmenus/,\$ d"
}
#convert xshl tags into texinfo
totexinfo1()
{
sed 's/@/@@/g
s/^[ ]*//g
s/[ ]*$//g
s/[ ][ ]*/ /g
s/{/@{/g
s/}/@}/g
s/^%%%*//g
s/^\%[a-z_0-9 ]*$//g
'
}
totexinfo()
{
sed '
s/<submenu>//g
s/<noprint>/@ifinfo/g
s/<\/noprint>/@end ifinfo/g
/<menuitems>/, /<\/menuitems>/ s/<p><a \([^>]*\)>\([^<]*\)<\/a>/* \1:: \2/g
s/<menuitems>/@menu /g
s/<\/menuitems>/@end menu /g
s/<tutor [^>]*>//g
s/<\/tutor>//g
/<notex>/,/<\/notex>/ d
s/--/---/g
s/^<p><tt>$/\
\
@example/g
s/^<\/tt><p>$/@end example\
\
/g
s/<math>/@math{/g
s/<\/math>/}/g
s/<tt>/@code{/g
s/<\/tt>/}/g
s/<emph>/@emph{/g
s/<\/emph>/}/g
s/^<p>$//
s/<p>/\
\
/g
s/<dl>/@table @strong/g
s/<\/dl>/@end table/g
s/<dt>/@item /g
s/<br>//g
s/^<dd>//g
s/<dd>/\
/g
s/<node \([^,]*\),\([^,]*\),\([^,]*\),\([^>]*\)>/@node \1, \3, \2, \4/g
s/<a \([^>]*\)>\(.*\)<\/a>\./\2. @xref{\1}./g
s/<a \([^>]*\)>\(.*\)<\/a>/\2/g
'
}
#convert headers to make new chapter
chapter()
{
sed '1,/<\/head>/ s/<head>/@chapter /g
s/<\/head>//g
s/<head>/@section /g
'
}
menu()
{
sed '
s/<p><emph>Syntax<\/emph>:(\([^)]*\))/@defun \1 \
@end defun/g
s/<main><head>/@appendix /g
s/<menuhead><head>/@appendixsec /g
s/<head>/@appendixsubsec /g
s/<center>//g
s/<\/center>//g
s/<\/head>//g
s/<\/main>//g
s/<\/menuhead>//g
'
#s/<main><head>/@chapter /g
#s/<menuhead><head>/@section /g
#s/<head>/@subsection /g
#s/<head>/@unnumberedsubsec /g
}
section()
{
sed '1,/<\/head>/ s/<head>/@section /g
s/<\/head>//g
s/<head>/@subsection /g
'
}
appendix()
{
sed '1,/<\/head>/ s/<head>/@appendix /g
s/<\/head>//g
s/<head>/@subsection /g
'
}
case "$1" in
chapter) keyword $2 | totexinfo1 | totexinfo | chapter ;;
section) keyword $2 | totexinfo1 | totexinfo | section ;;
appendix) keyword $2 | totexinfo1 | totexinfo | appendix ;;
menus) menus | totexinfo1 | menu | totexinfo ;;
esac
|