File: hxtoc.1

package info (click to toggle)
html-xml-utils 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,620 kB
  • sloc: ansic: 10,027; sh: 2,135; lex: 189; yacc: 125; perl: 123; makefile: 122
file content (126 lines) | stat: -rw-r--r-- 3,057 bytes parent folder | download
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
.de d \" begin display
.sp
.in +4
.nf
..
.de e \" end display
.in -4
.fi
.sp
..
.TH "HXTOC" "1" "10 Jul 2011" "6.x" "HTML-XML-utils"
.SH NAME
hxtoc \- insert a table of contents in an HTML file
.SH SYNOPSIS
.B hxtoc
.RB "[\| " \-x " \|]"
.RB "[\| " \-l
.IR low " \|]"
.RB "[\| " \-h
.IR high " \|]"
.RI "[\| " file " \|]"
.RB "[\| " \-t " \|]"
.RB "[\| " \-d " \|]"
.RB "[\| " \-c
.IR class " \|]"
.SH DESCRIPTION
.LP
The
.B hxtoc
command reads an HTML file, inserts missing ID attributes in all H1 to
H6 elements between the levels
.B \-l
and
.B \-h
(unless the option
.B \-d
is in effect, see below) and also inserts A elements with NAME
attributes, so old browsers will recognize the H1 to H6 headers as
target anchors as well (unless the option
.B \-t
is in effect). The output is written to stdout.
.LP
If there is a comment of the form
.d
<!\-\-toc\-\->
.e
or a pair of comments
.d
<!\-\-begin-toc\-\->
\&...
<!\-\-end-toc\-\->
.e
then the comment, or the pair with everything in between, will be
replaced by a table of contents, consisting of a list (UL) of links to
all headers in the document.
.LP
The text of headers is copied to this table of contents, including any
inline markup, except that DFN tags and SPAN tags with a CLASS of
"index" are omitted (but the elements content is copied).
.LP
If a header has a CLASS attribute with as value (or one of its values)
the keyword "no-toc", then that header will not appear in the table
of contents.
.SH OPTIONS
The following options are supported:
.TP 10
.B \-x
Use XML conventions: empty elements are written with a slash at the
end: <IMG\ />
.TP
.BI \-l " low"
Sets the lowest numbered header to appear in the table of
content. Default is 1 (i.e., H1).
.TP
.BI \-h " high"
Sets the highest numbered header to appear in the table of
content. Default is 6 (i.e., H6).
.TP
.B \-t
Normally,
.B hxtoc
adds both ID attributes and empty A elements with a NAME attribute and
CLASS="bctarget", so that older browsers that do no understand ID will
still find the target. With this option, the A elements will not be
generated.
.TP
.BI \-c " class"
The generated UL elements in the table of contents will have a CLASS attribute with the value
.I class.
The default is "toc".
.TP
.B \-d
Tries to use DIV elements as targets instead of H1 to H6: If a header
element H1 to H6 within the range
.B \-l
to
.B \-h
is found
.I and
it is the first child of a DIV element, then the table of contents
will link to the DIV instead of to the header element. The DIV will be
given an ID if it doesn't have one yet.
ID
.SH OPERANDS
The following operand is supported:
.TP 10
.I file
The name of an HTML file. If absent, standard input is read instead.
.SH "DIAGNOSTICS"
The following exit values are returned:
.TP 10
.B 0
Successful completion.
.TP
.B > 0
An error occurred in the parsing of the HTML file.
.B hxtoc
will try to correct the error and produce output anyway.
.SH "SEE ALSO"
.BR asc2xml (1),
.BR hxnormalize (1),
.BR hxnum (1),
.BR xml2asc (1)
.SH BUGS
.LP
The error recovery for incorrect HTML is primitive.