This file is indexed.

/usr/bin/gjots2html is in gjots2 2.4.1-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
#!/bin/sh
#
# Copyright (C) 1997-2002 Bob Hepple
# 
# A simple script to convert a gjots file to an HTML page - with table of contents
# etc
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later
# version.
# 
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more
# details.
# 
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
# 02139, USA.
#
# This would probably be easier for most people to understand if it
# were in perl(1)... but it's in sh, awk and m4. Anyone want to
# rewrite it?

usage() {
    echo "Usage: $PROG [-l] [-c] [-t \"title text\"] [filename]
Converts a gjots file to html (on stdout)

    -c:           adds a link to the TABLE OF CONTENTS after each section
    -i level:     indexes up to level (default is all levels)
    -l:           adds <HR> lines after each section
    -t \"title\": adds a title to the page
"
}

PROG=`basename $0`
ADD_HR=''
ADD_CLINK=''
ADD_TITLE=''
LEVEL="100"
ARGS=`getopt -o chi:lt: -- "$@"`
[ $? != 0 ] && echo "use -h for usage" >&2 && exit 1

eval set -- "$ARGS"

while true; do
    case $1 in
    -c) ADD_CLINK='yes'; shift;;
    -i) LEVEL="$2"; shift 2;;
    -l) ADD_HR='yes'; shift;;
    -t) ADD_TITLE="$2"; shift 2;;
    -h) usage; exit 0;;
    --) shift; break;;
    *)  echo "$PROG: internal error" >&2 ; exit 1;;
    esac
done

#echo "ADD_HR=$ADD_HR" >&2
#echo "ADD_CLINK=$ADD_CLINK" >&2
#echo "ADD_TITLE=$ADD_TITLE" >&2
#echo "ARGS=$@" >&2
#exit 0

FILENAME=""
[ -r $1 ] && FILENAME=$1

writeHeader() {

# Quote the here-document terminator word to disable shell variable expansion:
cat <<"EOF"
m4_divert(-1)
m4_changecom(`[[[[')m4_dnl to protect the # character
m4_changequote({{{{,}}}})
m4_define({{{{_Start_TOC}}}},{{{{<P>
<UL>
m4_divert(-1)
m4_define({{{{_H1_num}}}},0)
m4_define({{{{_H2_num}}}},0)
m4_define({{{{_H3_num}}}},0)
m4_define({{{{_H4_num}}}},0)
m4_define({{{{_H5_num}}}},0)
m4_define({{{{_H6_num}}}},0)
m4_define({{{{_H7_num}}}},)
m4_define({{{{_H8_num}}}},)
m4_define({{{{_H1_end}}}},)
m4_define({{{{_H2_end}}}},)
m4_define({{{{_H3_end}}}},)
m4_define({{{{_H4_end}}}},)
m4_define({{{{_H5_end}}}},)
m4_define({{{{_H6_end}}}},)
m4_define({{{{_H7_end}}}},)
m4_define({{{{_H8_end}}}},)
m4_divert(1)}}}})

m4_define({{{{_H1}}}}, {{{{m4_divert(-1)
m4_define({{{{_H1_num}}}},m4_incr(_H1_num))m4_dnl
m4_define({{{{_H2_num}}}},0)
m4_define({{{{_H3_num}}}},0)
m4_define({{{{_H4_num}}}},0)
m4_define({{{{_H5_num}}}},0)
m4_define({{{{_H6_num}}}},0)
m4_define({{{{_H7_num}}}},0)
m4_define({{{{_H8_num}}}},0)
m4_define({{{{_TOC_label}}}},{{{{_H1_num. $1}}}})
m4_divert(0)m4_dnl
_H8_end()m4_define({{{{_H8_end}}}},)m4_dnl
_H7_end()m4_define({{{{_H7_end}}}},)m4_dnl
_H6_end()m4_define({{{{_H6_end}}}},)m4_dnl
_H5_end()m4_define({{{{_H5_end}}}},)m4_dnl
_H4_end()m4_define({{{{_H4_end}}}},)m4_dnl
_H3_end()m4_define({{{{_H3_end}}}},)m4_dnl
_H2_end()m4_define({{{{_H2_end}}}},)m4_dnl
  <LI><A HREF="#_TOC_label">_TOC_label</A>
m4_divert(1)<H2><A NAME="_TOC_label">_TOC_label</A></H2>}}}})

m4_define({{{{_H2}}}}, {{{{m4_divert(-1)
m4_define({{{{_H2_end}}}},m4_ifelse(m4_eval(_LEVEL>=2),1,{{{{  </UL>
}}}},))
m4_define({{{{_H2_start}}}},m4_ifelse(_H2_num,0,{{{{  <UL>
}}}},))
m4_define({{{{_H2_num}}}},m4_incr(_H2_num))
m4_define({{{{_H3_num}}}},0)
m4_define({{{{_H4_num}}}},0)
m4_define({{{{_H5_num}}}},0)
m4_define({{{{_H6_num}}}},0)
m4_define({{{{_H7_num}}}},0)
m4_define({{{{_H8_num}}}},0)
m4_define({{{{_TOC_label}}}},{{{{_H1_num._H2_num $1}}}})
m4_divert(0)m4_dnl
_H8_end()m4_define({{{{_H8_end}}}},)m4_dnl
_H7_end()m4_define({{{{_H7_end}}}},)m4_dnl
_H6_end()m4_define({{{{_H6_end}}}},)m4_dnl
_H5_end()m4_define({{{{_H5_end}}}},)m4_dnl
_H4_end()m4_define({{{{_H4_end}}}},)m4_dnl
_H3_end()m4_define({{{{_H3_end}}}},)m4_dnl
m4_ifelse(m4_eval(_LEVEL>=2),1,{{{{_H2_start    <LI><A HREF="#_TOC_label">_TOC_label</A>
}}}})m4_divert(1)<H3><A NAME="_TOC_label">_TOC_label</A></H3>}}}})

m4_define({{{{_H3}}}}, {{{{m4_divert(-1)
m4_define({{{{_H3_end}}}},m4_ifelse(m4_eval(_LEVEL>=3),1,{{{{    </UL>
}}}},))
m4_define({{{{_H3_start}}}},m4_ifelse(_H3_num,0,{{{{    <UL>
}}}},))
m4_define({{{{_H3_num}}}},m4_incr(_H3_num))
m4_define({{{{_H4_num}}}},0)
m4_define({{{{_H5_num}}}},0)
m4_define({{{{_H6_num}}}},0)
m4_define({{{{_H7_num}}}},0)
m4_define({{{{_H8_num}}}},0)
m4_define({{{{_TOC_label}}}},{{{{_H1_num._H2_num._H3_num $1}}}})
m4_divert(0)m4_dnl
_H8_end()m4_define({{{{_H8_end}}}},)m4_dnl
_H7_end()m4_define({{{{_H7_end}}}},)m4_dnl
_H6_end()m4_define({{{{_H6_end}}}},)m4_dnl
_H5_end()m4_define({{{{_H5_end}}}},)m4_dnl
_H4_end()m4_define({{{{_H4_end}}}},)m4_dnl
m4_ifelse(m4_eval(_LEVEL>=3),1,{{{{_H3_start      <LI><A HREF="#_TOC_label">_TOC_label</A>
}}}})m4_divert(1)<H4><A NAME="_TOC_label">_TOC_label</A></H4>}}}})

m4_define({{{{_H4}}}}, {{{{m4_divert(-1)
m4_define({{{{_H4_end}}}},m4_ifelse(m4_eval(_LEVEL>=4),1,{{{{      </UL>
}}}},))
m4_define({{{{_H4_start}}}},m4_ifelse(_H4_num,0,{{{{      <UL>
}}}},))
m4_define({{{{_H4_num}}}},m4_incr(_H4_num))
m4_define({{{{_H5_num}}}},0)
m4_define({{{{_H6_num}}}},0)
m4_define({{{{_H7_num}}}},0)
m4_define({{{{_H8_num}}}},0)
m4_define({{{{_TOC_label}}}},{{{{_H1_num._H2_num._H3_num._H4_num $1}}}})
m4_divert(0)m4_dnl
_H8_end()m4_define({{{{_H8_end}}}},)m4_dnl
_H7_end()m4_define({{{{_H7_end}}}},)m4_dnl
_H6_end()m4_define({{{{_H6_end}}}},)m4_dnl
_H5_end()m4_define({{{{_H5_end}}}},)m4_dnl
m4_ifelse(m4_eval(_LEVEL>=4),1,{{{{_H4_start        <LI><A HREF="#_TOC_label">_TOC_label</A>
}}}})m4_divert(1)<H5><A NAME="_TOC_label">_TOC_label</A></H5>}}}})

m4_define({{{{_H5}}}}, {{{{m4_divert(-1)
m4_define({{{{_H5_end}}}},m4_ifelse(m4_eval(_LEVEL>=5),1,{{{{        </UL>
}}}},))
m4_define({{{{_H5_start}}}},m4_ifelse(_H5_num,0,{{{{        <UL>
}}}},))
m4_define({{{{_H5_num}}}},m4_incr(_H5_num))
m4_define({{{{_H6_num}}}},0)
m4_define({{{{_H7_num}}}},0)
m4_define({{{{_H8_num}}}},0)
m4_define({{{{_TOC_label}}}},{{{{_H1_num._H2_num._H3_num._H4_num._H5_num $1}}}})
m4_divert(0)m4_dnl
_H8_end()m4_define({{{{_H8_end}}}},)m4_dnl
_H7_end()m4_define({{{{_H7_end}}}},)m4_dnl
_H6_end()m4_define({{{{_H6_end}}}},)m4_dnl
m4_ifelse(m4_eval(_LEVEL>=5),1,{{{{_H5_start          <LI><A HREF="#_TOC_label">_TOC_label</A>
}}}})m4_divert(1)<H6><A NAME="_TOC_label">_TOC_label</A></H6>}}}})

m4_define({{{{_H6}}}}, {{{{m4_divert(-1)
m4_define({{{{_H6_end}}}},m4_ifelse(m4_eval(_LEVEL>=6),1,{{{{          </UL>
}}}},))
m4_define({{{{_H6_start}}}},m4_ifelse(_H6_num,0,{{{{          <UL>
}}}},))
m4_define({{{{_H6_num}}}},m4_incr(_H6_num))
m4_define({{{{_H7_num}}}},0)
m4_define({{{{_H8_num}}}},0)
m4_define({{{{_TOC_label}}}},{{{{_H1_num._H2_num._H3_num._H4_num._H5_num._H6_num $1}}}})
m4_divert(0)m4_dnl
_H8_end()m4_define({{{{_H8_end}}}},)m4_dnl
_H7_end()m4_define({{{{_H7_end}}}},)m4_dnl
m4_ifelse(m4_eval(_LEVEL>=6),1,{{{{_H6_start            <LI><A HREF="#_TOC_label">_TOC_label</A>
}}}})m4_divert(1)<H7><A NAME="_TOC_label">_TOC_label</A></H7>}}}})

m4_define({{{{_H7}}}}, {{{{m4_divert(-1)
m4_define({{{{_H7_end}}}},m4_ifelse(m4_eval(_LEVEL>=7),1,{{{{            </UL>
}}}},))
m4_define({{{{_H7_start}}}},m4_ifelse(_H7_num,0,{{{{            <UL>
}}}},))
m4_define({{{{_H7_num}}}},m4_incr(_H7_num))
m4_define({{{{_H8_num}}}},0)
m4_define({{{{_TOC_label}}}},{{{{_H1_num._H2_num._H3_num._H4_num._H5_num._H6_num._H7_num $1}}}})
m4_divert(0)m4_dnl
_H8_end()m4_define({{{{_H8_end}}}},)m4_dnl
m4_ifelse(m4_eval(_LEVEL>=7),1,{{{{_H7_start              <LI><A HREF="#_TOC_label">_TOC_label</A>
}}}})m4_divert(1)<H8><A NAME="_TOC_label">_TOC_label</A></H8>}}}})

m4_define({{{{_H8}}}}, {{{{m4_divert(-1)
m4_define({{{{_H8_end}}}},m4_ifelse(m4_eval(_LEVEL>=7),1,{{{{              </UL>
}}}},))
m4_define({{{{_H8_start}}}},m4_ifelse(_H8_num,0,{{{{              <UL>
}}}},))
m4_define({{{{_H8_num}}}},m4_incr(_H8_num))
m4_define({{{{_TOC_label}}}},{{{{_H1_num._H2_num._H3_num._H4_num._H5_num._H6_num._H7_num._H8_num $1}}}})
m4_divert(0)
m4_ifelse(m4_eval(_LEVEL>=8),1,{{{{_H8_start                <LI><A HREF="#_TOC_label">_TOC_label</A>
}}}})m4_divert(1)<H9><A NAME="_TOC_label">_TOC_label</A></H9>}}}})

m4_define({{{{_End_TOC}}}},{{{{m4_divert(0)m4_dnl
m4_ifelse(_H8_num,0,,{{{{              </UL>
}}}})m4_dnl
m4_ifelse(_H7_num,0,,{{{{            </UL>
}}}})m4_dnl
m4_ifelse(_H6_num,0,,{{{{          </UL>
}}}})m4_dnl
m4_ifelse(_H5_num,0,,{{{{        </UL>
}}}})m4_dnl
m4_ifelse(_H4_num,0,,{{{{      </UL>
}}}})m4_dnl
m4_ifelse(_H3_num,0,,{{{{    </UL>
}}}})m4_dnl
m4_ifelse(_H2_num,0,,{{{{  </UL>
}}}})m4_dnl
</UL>
<P>}}}})
m4_divert m4_dnl
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML> 
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
EOF

cat <<EOF
  <TITLE>$FILENAME</TITLE>
</HEAD>
<BODY>

EOF
} # writeHeader

writeBody() {

    TMP="/tmp/gjots2html.$$.awk"
    trap "rm -f $TMP" EXIT

    cat > $TMP <<'EOF'
BEGIN {
    level = 1
    print_title=1
    #printf("add_hr=%s\n", add_hr) | "cat 1>&2"
    #printf("add_clink=%s\n", add_clink) | "cat 1>&2"
    #printf("add_title=%s\n", add_title) | "cat 1>&2"
    if (add_title != "") {
        printf("<H1>%s</H1><P>\n", add_title)
    }
    print "<A NAME=\"Contents\">Contents</A><P>_Start_TOC\n<PRE>\n"
}

{
    if ($0 ~ /^\\NewEntry/) { 
        print_title=1
    } else if ($0 ~ /^\\NewFolder/) { 
        level++
        if (level > 8) {
            print "gjots2html: Too many levels of folder for this poor utility. Bailing out!" >"/dev/stderr"
            exit 1
        }
    } else if ($0 ~ /^\\EndFolder/) { 
        level--
    } else {
        gsub(/&/,"\\&amp;")
        gsub(/"/,"\\&quot;")
        gsub(/</,"\\&lt;")
        gsub(/>/,"\\&gt;")
        if (print_title) {
            # the first line is the title:
            printf("</PRE>\n")
            if (add_clink == "yes") {
                printf("<P><A HREF=\"#Contents\">Contents</A><P>")
            }
            if (add_hr == "yes") {
                printf("<HR>\n")
            }
            printf("_H%d(%s)\n<PRE>\n",level, $0)
            print_title=0
        } else {
            print
        }
    }
}

END { print "</PRE>\n"; }
EOF

    awk -v add_hr="$ADD_HR" -v add_clink="$ADD_CLINK" \
        -v add_title="$ADD_TITLE" -f $TMP $FILENAME 

} # writeBody

writeTrailer() {
cat <<"EOF"
</BODY>
</HTML>
_End_TOC
EOF
} # writeTrailer

# This is the main program (!):
(
    writeHeader
    writeBody
    writeTrailer
) | m4 -P -D_LEVEL=$LEVEL