This file is indexed.

/usr/bin/gjots2docbook 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
#!/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.
#

usage() {
	echo "Usage: $PROG -a | -b [-e] [-P] [-p] [ filename ]
Converts a gjots file to DOCBOOK XML (on stdout)
	-a: make an article
	-b: make a book
	-e: don't encode special characters eg < -> &lt;
	-p: don't change blank lines to </para><para> markers 
	-P: first section is a preface rather than a chapter (book only)

Either -a or -b must be given but not both. Items in the root element should 
contain <bookinfo> or <artheader>. If the file does not start with <?xml ...> 
then appropriate lines will be added. The -e and -p options are provided in 
case your gjots file is already partially in docbook format.

If properly installed, the docbook utilities can then be used to create HTML, 
man, ps, pdf etc files eg:

$PROG -b ~/.gjotsfile >gjotsfile.xml
docbook2pdf gjotsfile.xml

It may be necessary to fine-tune the docbook formatting to access all features."
}

abend() {
	echo "$PROG: $1" >&2
	echo "(Use -h for usage)" >&2
	exit 1
}

PROG=`basename $0`
DOC_TYPE='"unknown"'
ADD_PARA='"yes"'
HAS_PREFACE='""'
ENCODE_SPECIALS='"yes"'

ARGS=`getopt -o abepPh -- "$@"`
[ $? != 0 ] && echo "use -h for usage" >&2 && exit 1

eval set -- "$ARGS"

while true; do
	case $1 in
		-a) DOC_TYPE='"article"'; shift;;
		-b) DOC_TYPE='"book"'; shift;;
		-e) ENCODE_SPECIALS='""'; shift;;
		-p) ADD_PARA='""'; shift;;
		-P) HAS_PREFACE='"yes"'; shift;;
		-h) usage; exit 0;;
		--) shift; break;;
		*)  echo "$PROG: internal error" >&2 ; exit 1;;
	esac
done

if [ "$DOC_TYPE" = '"unknown"' ]; then
	abend "must give either -a or -b options"
fi

if [ "$DOC_TYPE" = '"article"' ] ; then
	if [ "$HAS_PREFACE" = '"yes"' ]; then
		abend "-P option is only valid with -b"
	fi
fi

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


writeBody() {
AWKFILE=/tmp/gjots2docbook.tmp$$.awk 

# Leave the here-document terminator unquoted to enable shell variable expansion:
# $ \ ` and , need escaping with \:
cat >$AWKFILE <<EOF
BEGIN {
	level = 1
	add_para = $ADD_PARA
	has_preface = $HAS_PREFACE
	doc_type = $DOC_TYPE
	encode_specials = $ENCODE_SPECIALS
	xml_done = 0
	docbook_done = 0
	main_element = 0
	title_open = 0
	print_title=1
}

function print_indent() {
	for (iterator = 0; iterator < level; iterator++)
		printf("    ")
}

function close_title() {
	if (!title_open) {
		return
	}

	print_indent()
	print "</para>"

	while (title_open >= level) {
		title_element = "section"
		if (doc_type == "book") {
			if ( title_open == 1 ) {
				if ( has_preface ) {
					title_element = "preface"
				} else {
					title_element = "chapter"
				}
			}
		}
		print_indent()
		printf("</%s>\\n", title_element)
		title_open--;
	}
	has_preface = 0
}

function open_title(title) {
	if (title_open) {
		close_title()
	}
	title_element = "section"
	if (doc_type == "book") {
		if ( level == 1 ) {
			if ( has_preface ) {
				title_element = "preface"
			} else {
				title_element = "chapter"
			}
		}
	}
	print_indent()
	printf("<%s><title>%s</title>\\n", title_element, title)
	print_indent()
	print "<para>"
	title_open = level
}

{
	if ( ! xml_done ) {
		xml_done = 1
		if ( \$0 ~ "<\\?xml" || \$0 ~ "<\\?XML" ) {
			print \$0
			next
		} else {
			print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
		}
	}

	if ( ! docbook_done) {
		docbook_done = 1
		if ( \$0 ~  "<DOCTYPE" || \$0 ~ "<doctype" ) {
			print \$0
			next
		} else {
			printf("<!DOCTYPE %s PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\">\n",doc_type)
		}
	}
		
	if (!main_element) {
		main_element=1
		printf("<%s>\\n", doc_type)
	}

	if (\$0 ~ /^\\\\NewEntry/) { 
		print_title=1
	} else if (\$0 ~ /^\\\\NewFolder/) { 
		level++
	} else if (\$0 ~ /^\\\\EndFolder/) { 
		level--
	} else {
		if (encode_specials) {
			gsub(/&/,"\\\\&amp;")
			gsub(/"/,"\\\\&quot;")
			gsub(/</,"\\\\&lt;")
			gsub(/>/,"\\\\&gt;")
		}
		if (print_title) {
			open_title(\$0)
			print_title=0
		} else if ( add_para && \$0 ~ "^[ 	]*\$") {
			print_indent()
			print "</para><para>"
		} else {
			print_indent()
			print
		}
	}
}

END { 
	while (level) {
		close_title()
		level--;
	}
	printf("</%s>\n",doc_type)
}

EOF

cat $FILENAME | awk -f $AWKFILE
rm $AWKFILE

} # writeBody

# This is the main program (!):
(
		writeBody
)