File: hxtoc.1

package info (click to toggle)
html-xml-utils 7.7-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,488 kB
  • sloc: ansic: 11,213; sh: 7,996; lex: 243; makefile: 193; yacc: 125
file content (145 lines) | stat: -rw-r--r-- 4,272 bytes parent folder | download | duplicates (3)
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
.de d \" begin display
.sp
.in +4
.nf
..
.de e \" end display
.in -4
.fi
.sp
..
.TH "HXTOC" "1" "10 Jul 2011" "7.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 " \|]"
.RB "[\| " \-t " \|]"
.RB "[\| " \-d " \|]"
.RB "[\| " \-c
.IR class " \|]"
.RB "[\| " \-f " \|]"
.RI "[\| " file-or-URL " \|]"
.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 ID attributes, DFN tags and SPAN tags with
a CLASS of "index" are omitted (but the elements' content is copied).
.LP
The copied text can optionally be "flattened" first, see option
.BR \-f .
.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 sectioning elements as targets in the table of contents
instead of H1 to H6. A sectioning elements is a DIV, SECTION, ARTICLE,
ASIDE or NAV element whose first child is a heading element (H1 to H6)
or an HGROUP. The sectioning element will be given an ID if it doesn't
have one yet. With this option, the level of any H1 to H6 that is the
first child of a sectioning element (or of an HGROUP that is itself
the first child of a sectioning element) is not determined by its
name, but by the nesting depth of the sectioning elements. (Any H1 to
H6 that are not the first child of a sectioning element still have
their level implied by their name.)
.TP
.B \-f
Flatten the text of the table of contents. Without
.BR \-f ,
the contents of header elements are copied to the table of contents
almost unchanged, i.e., including any child elements and their
attributes (except for ID attributes, DFN elements and certain SPAN
elements, as explained above). With
.BR \-f ,
the contents are flattened instead: All child elements are removed and
only their contents are copied to the table of contents. Additionally
elements with an ALT attribute, such as IMG, are replaced by the
contents of the ALT attribute. Exception: BDO tags are copied
unchanged and elements with a DIR attribute are replaced by a SPAN
with that DIR attribute. (BDO and DIR may occur in languages written
right-to-left.)
.SH OPERANDS
The following operand is supported:
.TP 10
.I file-or-URL
The name or URL 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.