Codebase list html-xml-utils / 5b98a3a6-d5ac-491c-8cfe-5a693ac63d92/upstream/8.6 hxaddid.1
5b98a3a6-d5ac-491c-8cfe-5a693ac63d92/upstream/8.6

Tree @5b98a3a6-d5ac-491c-8cfe-5a693ac63d92/upstream/8.6 (Download .tar.gz)

hxaddid.1 @5b98a3a6-d5ac-491c-8cfe-5a693ac63d92/upstream/8.6raw · history · blame

.de d \" begin display
.sp
.in +4
.nf
..
.de e \" end display
.in -4
.fi
.sp
..
.TH "HXADDID" "1" "10 Jul 2011" "7.x" "HTML-XML-utils"
.SH NAME
hxaddid \- add IDs to selected elements
.SH SYNOPSIS
.B hxaddid
.RB "[\| " \-x " \|]"
.RB "[\-\-]"
.IR elem|.class|elem.class
.RI "[\| " file-or-URL " \|]"
.SH DESCRIPTION
.LP
The
.B hxaddid 
command copies an HTML or XML file to standard output, while adding
element IDs to the specified elements or classes.
.LP
For example, given the input
.d
<p>A paragraph without an ID</p>
.e
the command
.d
hxaddid p
.e
will output
.d
<p id="a-paragraph">A paragraph without an ID</p>
.e
.LP
If you specify a class using \fB.class\fP then IDs will only be added
to elements that contain that class.  And if you specify an element and
a class using \fBelem.class\fP then IDs will only be added to the 
specified elements that contain the specified class.
.LP
If two elements would naturally generate the same ID, a number is 
added to the ID name (starting with 0) to make sure the IDs are 
unique.  IDs are not added to matching elements that already contain 
an ID.
.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\ />. Also causes the element to be matched case-sensitively.
.SH OPERANDS
The following operands are supported:
.TP 10
.I elem
The name of element to select.
.TP 10
.I .class
The name of class to select.
.TP 10
.I elem.class
The name of element that contains class to select.
.TP 10
.I file-or-URL
The name or URL of an HTML or XHTML file.
.SH "EXIT STATUS"
The following exit values are returned:
.TP 10
.B 0
Successful completion.
.TP
.B > 0
An error occurred in the parsing of one of the HTML or XML files.
.SH ENVIRONMENT
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. Instead
pipe the input through
.BR hxunent (1)
and
.BR asc2xml (1)
to convert it to UTF-8.
.LP
.B hxaddid
tries first to generate "readable" IDs, by forming the ID out of the
letters and digits found in the content of the element and falls back
to generating arbitrary IDs if it doesn't find enough. However, the
algorithm in this version is primitive and only gives reasonable
results for ASCII letters and digits.
.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 hxprune (1),
.BR hxnormalize (1),
.BR hxnum (1),
.BR hxtoc (1),
.BR hxunent (1),
.BR xml2asc (1),
.BR UTF-8 " (RFC 2279)"