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
|
.de d \" begin display
.sp
.in +4
.nf
..
.de e \" end display
.in -4
.fi
.sp
..
.TH "HXINDEX" "1" "10 Jul 2011" "6.x" "HTML-XML-utils"
.SH NAME
hxindex \- insert an index into an HTML document
.SH SYNOPSIS
.B hxindex
.RB "[\| " \-t " \|]"
.RB "[\| " \-x " \|]"
.RB "[\| " \-n " \|]"
.RB "[\| " \-f " \|]"
.RB "[\| " \-r " \|]"
.RB "[\| " \-c
.IR classes " \|]"
.RB "[\| " \-b
.IR base " \|]"
.RB "[\| " \-i
.IR indexdb " \|]"
.RB "[--]"
.RI "[\| " file\-or\-URL " \|]"
.SH DESCRIPTION
.LP
The
.B hxindex
looks for terms to be indexed in a document, collects them, turns them
into target anchors and creates a sorted index as an HTML list, which
is inserted at the place of a placeholder in the document. The
resulting document is written to standard output.
.LP
The index is inserted at the place of a comment of the form
.d
<!--index-->
.e
or between two comments of the form
.d
<!--begin-index-->
\&...
<!--end-index-->
.e
In the latter case, all existing content between the two comments is
removed first.
.LP
Index terms are either elements of type \fI<dfn>\fP or elements with a
class attribute of \fI"index".\fP (For backward compatibility, also
class attributes \fI"index-inst"\fP and \fI"index-def"\fP are
recognized.) \fI<dfn>\fP elements (and class \fI"index-def"\fP) are
considered more important than elements with class \fI"index"\fP and
will appear in bold in the generated index.
.LP
The option
.B \-c
adds additional classes, that are aliases for \fI"index"\fP.
.LP
By default, the contents of the element are taken as the index term.
Here are two examples of occurrences of the index term "shoe":
.d
A <dfn>shoe</dfn> is a piece of clothing that...
completed by a leather <span class="index">shoe</span>...
.e
.LP
If the term to be indexed is not equal to the contents of the element,
the \fItitle\fP attribute can be used to give the correct term:
.d
\&... <dfn title="shoe">Shoes</dfn> are pieces of clothing that...
\&... with two leather <span class="index" title="shoe">shoes</span>...
.e
.LP
The \fItitle\fP attribute must also be used when the index term is a
subterm of another. Subterms appear indented in the index, under their
head term. To define a subterm, use a \fItitle\fP attribute with two
exclamation marks ("!!") between the term and the subterm, like this:
.d
<dfn title="shoe!!leather">...</dfn>
<dfn title="shoe!!invention of">...</dfn>
<em class="index" title="shoe!!protective!!steel nosed">...</em>
.e
As the last example above shows, there can be multiple levels of
sub-subterms.
.LP
The \fItitle\fP attribute also allows multiple index terms to be
associated with a single occurrence. The multiple terms are separated
with a vertical bar ("|"). Compare the following examples with the
ones above:
.d
<dfn title="shoe|boot">...</dfn>
<dfn title="shoe!!invention of|inventions!!shoe">...</dfn>
.e
These two elements both insert two terms into the index. Note that the
second example above combines subterms and multiple terms.
.LP
It is possible to run index on a file that already has an index. The
old target anchors and the old index will be removed before being
re-generated.
.SH OPTIONS
The following options are supported:
.TP 10
.B \-t
By default,
.B hxindex
adds an ID attribute to the element that contains the occurrence of a
term and
.I also
inserts an \fI<a>\fP element inside it with a \fIname\fP
attribute equal to the ID. This is to allow old browsers that ignore
ID attributes, such as
Netscape 4, to find the target as well. The
.B \-t
option suppresses the \fI<a>\fP element.
.TP
.B \-x
This option turns on XML syntax conventions: empty elements will end
in \fI/>\fP instead of \fI>\fP as in HTML.
.B \-x
implies
.B \-t.
.TP
.BI \-i " indexdb"
.B hxindex
can read an initial index from a file and write the merged collection
of index terms back to that file. This allows an index to span several
documents. The
.B \-i
option is used to give the name of the file that contains the index.
.TP
.BI \-b " base"
This option is useful in combination with
.B \-i
to give the base URL reference of the document. By default,
.B hxindex
will store links to occurrences in the \fIindexdb\fP file in the form
\fI#anchor\fP, but when
.B \-b
is given, the links will look like \fIbase#anchor\fP instead.
.TP
.BI \-c " class[,class[,...]]"
Normal index terms are recognized because they have a class of
\fI"index".\fP The
.B \-c
option adds additional, comma-separated class
names that will be considered aliases for \fI"index"\fP. E.g.,
.B \-c instance
will make sure that
.B <span class="instance">term</span>
is recognized as a term for the index.
.TP
.B \-n
By default, the index consists of links with "#" as the anchor text.
Option
.B \-n
causes the link text to consist of the section numbers of the sections
in which the terms occur, falling back to "#" only if no section
number could be found. Section numbers are found by looking for the
nearest preceding start tag with a class of "secno" or "no-num". In
the case of "secno", the contents of that element are taken as the
section number. In the case of "no-num" the section is assumed to have
no number and
.B hxindex
will print a "#" instead. These classes are also used by
.BR hxnum (1),
so it is useful to run
.B hxindex
.I after
.BR hxnum ", e.g.,"
.d
hxnum myfile.html | hxindex \-n >mynewfile.html
.e
.TP
.B \-f
Remove \fItitle\fP attributes that were used for the index as well as
the comments that delimit the inserted index. This avoids that
browsers display these attributes. Note that \fBhxindex\fP cannot be
run again on its own output if this option is used. (Mnemonic:
"\fBf\fPreeze" or "\fBf\fPinal".)
.TP
.B \-r
Do not ignore trailing punctuation when sorting index terms. E.g., if
two terms are written as
.d
<dfn>foo,</dfn>... <span class=index>foo</span>
.e
.B hxindex
will normally ignore the comma and treat them as the same term, but
with
.B \-r,
they are treated as different. This affects trailing commas (,),
semicolons (;), colons (:), exclamations mark (!), question marks (?)
and full stops (.). A final full stop is never ignored if there are
two or more in the term, to protect abbreviations ("B.C.") and
ellipsis ("more..."). This does
.I not
affect how the index term is printed (it is always printed as it
appears in the text), only how it is compared to similar
terms. (Mnemonic: "\fBr\fPaw".)
.SH OPERANDS
The following operand is supported:
.TP 10
.I file\-or\-URL
The name of an HTML or XML file or the URL of one. If absent, or if
the file is "-", standard input is read instead.
.SH "EXIT STATUS"
The following exit values are returned:
.TP 10
.B 0
Successful completion.
.TP
.B >0
An error occurred in parsing the HTML file.
.SH ENVIRONMENT
The input is assumed to be in UTF-8, but the current locale is used to
determine the sorting order of the index terms. I.e.,
.B hxindex
looks at the LANG, LC_ALL and/or LC_COLLATE environment variables. See
.BR locale (1).
.LP
To use a proxy to retrieve remote files, set the environment variables
.B http_proxy
or
.BR ftp_proxy "."
E.g.,
.B http_proxy="http://localhost:8080/"
.SH BUGS
.LP
Assumes UTF-8 as input. Doesn't expand character entities (apart from
the standard ones: "&", "<", ">" and """). Instead, pipe
the input through
.BR hxunent (1)
and, if needed,
.BR asc2xml (1)
to convert it to UTF-8.
.LP
Remote files (specified with a URL) are currently only supported for
HTTP. Password-protected files or files that depend on HTTP "cookies"
are not handled. (You can use tools such as
.BR curl (1)
or
.BR wget (1)
to retrieve such files.)
.SH "SEE ALSO"
.BR asc2xml (1),
.BR hxnormalize (1),
.BR hxnum (1),
.BR hxprune (1),
.BR hxtoc (1),
.BR hxunent (1),
.BR xml2asc (1),
.BR locale (1),
.BR UTF-8 " (RFC 2279)"
|