Next: Conditional Text
Up: No Title
Previous: Including Arbitrary HTML Mark-up
Arbitrary Tags and Attributes
For version 97.1 of LATEX2HTML there is a new command which provides
an extremely flexible way to include HTML 3.2 tags, along with
any values for the ``attributes'' of that tag, if desired.
\HTML[
<attribs>]{
<tag>}
\HTML[
<attribs>]{
<tag>}{
<contents>}
When the
<tag> also needs a closing tag (e.g <I>...</I>)
the
<contents> must be given, enclosed in braces.
Both the opening and closing tags then will be placed correctly.
An important aspect of this is that any of the
<tag>,
<attribs> and
<contents> may be given wholly
by expanding a LATEX macro, or may contain arbitrary macros,
perhaps including other \HTML commands.
The following table
was constructed using this feature; its LATEX source follows.
Figure:
Example use of macros for raw HTML code.
A listing of the different text styles available in HTML 3.2
- a simple test of ``bold-face'', using
<B> .
- a simple test of ``italics'', using
<I> .
- a simple test of ``teletype-text'', using
<TT> .
- a simple test of ``underlining'', using
<U> .
-
a simple test of ``strikeout'', using <STRIKE> .
- a simple test of ``emphasis style'', using
<EM> .
- a simple test of ``strong style'', using
<STRONG> .
-
a simple test of ``code style'', using <CODE> .
- a simple test of ``citation style'', using
<CITE> .
- a simple test of ``definition style'', using
<DFN> .
- a simple test of ``sample style'', using
<SAMP> .
- a simple test of ``keyboard style'', using
<KBD> .
- a simple test of ``variable style'', using
<VAR> .
|
|
\newcommand{\myalign}{center}
\newcommand{\mylist}{UL}
\newcommand{\myitem}[2]{\HTML[disc]{LI}{\simpletest{#1}{#2}}}
\newcommand{\simpletest}[2]{%
\HTML{#1}{ a simple test of ``#2'',} using \HTML{CODE}{<#1>} .}
\newcommand{\tableopts}{10,border=5}
\newcommand{\tablelist}[4][left]{\HTML[#1]{DIV}{
\HTML[\tableopts]{TABLE}{
\HTML[bottom]{CAPTION}{
#3
}\HTML{TR}{\HTML{TD}{
\HTML{#2}{
#4
}}}
}}\HTML[all]{BR}}
\tablelist[\myalign]{\mylist}{%
\textbf{A listing of the different text styles available in HTML 3.2}}{%
\myitem{B}{bold-face}
\myitem{I}{italics}
\myitem{TT}{teletype-text}
\myitem{U}{underlining}
\HTML[circle]{LI}{\simpletest{STRIKE}{strikeout}}
\myitem{EM}{emphasis style}
\myitem{STRONG}{strong style}
\myitem{CODE}{code style}
\myitem{CITE}{citation style}
\myitem{DFN}{definition style}
\HTML[square]{LI}{\simpletest{SAMP}{sample style}}
\HTML[square]{LI}{\simpletest{KBD}{keyboard style}}
\myitem{VAR}{variable style}}
The above code demonstrates many aspects of the way \HTML
commands can be used.
-
nesting:
- \HTML commands can be nested to arbitrary depth.
-
macros:
- Macros can be used to specify all or part of each argument.
-
within macros:
- \HTML commands work correctly within the expansions of other macros.
-
attribute values:
- Information within
<attribs> can be specified in a very
loose way, as a comma-separated list of key/value pairs
or as single values.
Not even the commas are necessary: space(s),
<tab>s
or newlines are equally effective.
Indeed the horizontal rules preceding and following the table were
specified by:
\HTML[50\% 3 noshade center]{HR}
-
attribute names:
- Usually it is not necessary to know the names of the
attributes to the tags that are to be used. It is sufficient
just to give the values; these will be matched to the
appropriate attribute, according to the type of data required.
(If names are given, these are case-insensitive.)
-
newlines:
- Although LATEX ignores linebreaks within the source code,
this is not so with LATEX2HTML.
The strange spreading-out of the definition of the
\tablelist command above was done with the purpose
solely of making the code in the resulting HTML files
more easily readable, to a human.
(As most browsers ignore those newlines anyway,
more compact code would have rendered the same on-screen.)
Some further aspects of the use of this \HTML
command are not apparent from the above example.
-
invalid
<tag>:
- If a
<tag> is specified that is not part of the
HTML 3.2 specifications, then it and its attributes are
not placed into the HTML document created by LATEX2HTML.
Any
<contents> is included as ordinary data;
i.e. as text in paragraphs, etc.
-
required attributes:
- Some tags have attributes which are required to have values,
if that tag is to be included in an HTML document.
Using the \HTML command, if any such attribute
is not given an appropriate value then the tag is ignored.
Any
<contents> are included in the document,
as ordinary character data.
-
valid HTML:
- Currently there is no checking that the
<contents>
of a
<tag> contains only data (perhaps including other tags)
allowed by the DTD for HTML 3.2.
The requirement to produce valid
HTML
currently rests with the user.
This issue will be addressed in forthcoming revisions of LATEX2HTML.
-
extra attributes and values:
- The list of attributes for a
<tag> can include
key-value pairs whose keys do not match any valid
attribute for the
<tag>.
Such key-value pairs are simply ignored.
Similarly extra data values are ignored,
as are values that do not match the
requirements for any valid attribute.
-
attributes with similar data-types:
- Several attributes to a
<tag> may use values having
the same or similar data-types. First any key-value pairs
are processed. Remaining values are allocated
to those attributes which do not already have a value.
An ordering of the attributes is used, based on a perceived likelihood
of each attribute being required to be changed from its default setting.
Next: Conditional Text
Up: No Title
Previous: Including Arbitrary HTML Mark-up
root
1998-02-23