unroff-website/www/doc/unroff-html.1.html

660 lines
21 KiB
HTML

<html>
<head>
<!-- This file has been generated by unroff 1.0, 03/21/96 19:29:21. -->
<!-- Do not edit! -->
<link rev="made" href="mailto:net@informatik.uni-bremen.de">
<!-- $Revision: 1.12 $ -->
<title>Manual page for unroff-html(1)</title>
</head>
<body>
<h2>
unroff-html - HTML 2.0 back-end for the programmable troff translator
<hr></h2>
<h2>SYNOPSIS</h2>
<b>unroff
</b>[
<b>-fhtml
</b>] [
<b>-m</b><i>package
</i>] [
<i>file</i> | <i>option...
</i>]
<h2>OVERVIEW</h2>
When called with the
<b>-fhtml
</b>option,
<i>unroff
</i>loads the back-end for the Hypertext Markup Language (HTML) version 2.0.<tt> </tt>
Please read
<b>unroff</b>(1)
first for an overview of the Scheme-based, programmable troff translator
and for a description of the generic options that exist in
addition to
<b>-f
</b>and
<b>-m</b>.<tt> </tt>
For information about extending and programming
<i>unroff
</i>also refer to the
<i>Unroff Programmer's Manual</i>.<tt> </tt>
<p>
<i>unroff
</i>is usually invoked with an additional
<b>-m</b><i>package
</i>option (such as
<b>-ms
</b>or
<b>-man</b>)
to load the translation rules for the troff macros and other elements
defined by the macro package that is used to typeset the document.<tt> </tt>
If no
<b>-m
</b>option is supplied, only the standard troff requests, special characters,
escape sequences, etc. are recognized and translated to HTML by
<i>unroff
</i>as described in this manual.<tt> </tt>
<h2>OPTIONS</h2>
The following HTML-specific options can be specified in the command
line after the generic options.<tt> </tt>
See
<b>unroff</b>(1)
for a general description of keyword/value options and their types
and for a list of options that are not specific to the target language.<tt> </tt>
<dl>
<dt><b>title</b> (string)
<dd>
The value to be used for the &lt;title&gt; element in HTML output files.<tt> </tt>
This option may be ignored by the code implementing a specific
macro set, e.g. when special rules are employed to derive the title
from the contents of the troff input files.<tt> </tt>
Whether or not this option is required also depends on the specific
<b>-m
</b>option used, but it may be omitted if no
<b>-m
</b>option is given.<tt> </tt>
<dt><b>document</b> (string)
<dd>
The prefix used for the names of all output files.<tt> </tt>
May be ignored depending on the macro package that has been selected.<tt> </tt>
<dt><b>mail-address</b> (string)
<dd>
The caller's mail address; may be used for ``mailto:'' URLs,
in particular for the ``href'' attribute of the &lt;link&gt;
element that is usually generated.<tt> </tt>
<dt><b>tt-preformat</b> (boolean)
<dd>
If 1, font changes to a font that is mapped to the &lt;tt&gt; element
are honored inside non-filled text (as described below).<tt> </tt>
The default is 0, i.e. the font changes will be recorded, but no
corresponding HTML tags will be emitted for them.<tt> </tt>
<dt><b>handle-eqn</b> (string)
<dd>
<dt><b>handle-tbl</b> (string)
<dd>
<dt><b>handle-pic</b> (string)
<dd>
These options specify how equations, tables, and pictures encountered
in the troff input are processed.<tt> </tt>
Possible values are ``copy'' to include the raw eqn, tbl, or
pic commands as pre-formatted text, ``text'' to run the
respective troff preprocessor (eqn, tbl, or pic) and include its output
as pre-formatted text, or ``gif'' to convert the preprocessor
output to a GIF image and include it in the HTML document as
an inline image.<tt> </tt>
The default is ``text'' for
<b>handle-tbl</b>,
``gif'' for the other options.<tt> </tt>
See DESCRIPTION below for more information.<tt> </tt>
<dt><b>eqn</b> (string)
<dd>
<dt><b>tbl</b> (string)
<dd>
<dt><b>pic</b> (string)
<dd>
These options specify the programs to invoke as the eqn, tbl,
and pic preprocessors.<tt> </tt>
The defaults are site-dependent.<tt> </tt>
<dt><b>troff-to-text</b> (string)
<dd>
<dt><b>troff-to-gif</b> (string)
<dd>
The programs to invoke for converting the output of a troff preprocessor
to plain text or to a GIF image.<tt> </tt>
The default values are site-dependent.<tt> </tt>
See DESCRIPTION below for more information on these options.<tt> </tt>
</dl>
<h2>FILES</h2>
If no
<b>-m
</b>option is supplied,
<i>unroff
</i>reads the specified input files and sends the HTML document to
standard output, unless the
<b>document
</b>option is given, in which case its value together
with the suffix ``.html'' is used as the name of an
output file.<tt> </tt>
If no input files are specified, input is taken from standard input.<tt> </tt>
The output is enclosed by the usual HTML boiler-plate (&lt;html&gt;, &lt;head&gt;,
and &lt;body&gt; elements), a &lt;title&gt; element with the specified title
(or the value of
<b>document
</b>if no title has been given, or a default title if both are omitted),
a &lt;link&gt; element with rev= and href= attributes if
<b>mail-address
</b>has been set, and any pending end tags are generated on end of input.<tt> </tt>
<p>
Note that this is the default action that is performed in the
rare case when no macro package name has been specified, i.e. when
processing ``bare'' troff input.<tt> </tt>
Somewhat different rules may apply when processing, for
example, a group of UNIX manual pages
(<b>-man</b>).<tt> </tt>
<p>
See
<b>unroff</b>(1)
for a list of Scheme files that are loaded on startup.<tt> </tt>
<h2>DESCRIPTION</h2>
<h3>OUTPUT TRANSLATIONS</h3>
The characters `&lt;', `&gt;', and `&amp;' are replaced by the entities
`&amp;lt;', `&amp;gt;', and `&amp;amp;' on output.<tt> </tt>
In addition, the quote character is mapped to `&amp;quot;' where
appropriate.<tt> </tt>
New mappings can be added by means of the
<i>defchar
</i>Scheme primitive as explained in the Programmer's Manual.<tt> </tt>
<h3>COMMENTS</h3>
each troff comment is translated to a corresponding HTML tag
followed by a newline; empty comments are ignored.<tt> </tt>
Comments are also ignored when appearing inside a macro body.<tt> </tt>
<h3>ESCAPE SEQUENCES</h3>
The following is a list of troff escape sequences that are recognized
and the HTML output generated for them.<tt> </tt>
Any escape sequence that does not appear in the list
expands to the character after the escape character, and
a warning is printed in this case.<tt> </tt>
New definitions can be added and the predefined mappings can
be replaced by calling the
<i>defescape
</i>Scheme primitive in the user's initialization file, in a user-supplied
Scheme file, in a document, or on a site-wide basis by modifying
the file
<b>scm/html/common.scm
</b>in the installation directory.<tt> </tt>
<p>
<pre>
\&amp; nothing
\- -
\| nothing
\^ nothing
\\ \
\' '
\` `
\" rest of line as HTML comment tag
\% nothing
\{ conditional input begin
\} conditional input end
\* contents of string
\space space
\0 space
\c nothing; eats following newline
\e \
\s nothing
\u nothing, prints warning
\d nothing, prints warning
\v nothing, prints warning
\o its argument, prints warning
\z its argument, prints warning
\k sets specified register to zero
\h appropriate number of spaces for positive argument
\w length of argument in units
\l repeats specified character, or &lt;hr&gt;
\n contents of number register
\f see description of fonts below
</pre>
<h3>SPECIAL CHARACTERS</h3>
The following special characters are mapped to their equivalent
ISO-Latin 1 entities:
<p>
<pre>
\(12 \(14 \(34 \(*b \(*m \(+- \(:A
\(:O \(:U \(:a \(:o \(:u \(A: \(Cs
\(O: \(Po \(S1 \(S2 \(S3 \(U: \(Ye
\(a: \(bb \(cd \(co \(ct \(de \(di
\(es \(hy \(mu \(no \(o: \(r! \(r?
\(rg \(sc \(ss \(tm \(u:
</pre>
<p>
Heuristics have to be used for the following special characters:
<p>
<pre>
\(** *
\(-&gt; -&gt;
\(&lt;- &lt;-
\(&lt;= &lt;=
\(== ==
\(&gt;= &gt;=
\(Fi ffi
\(Fl ffl
\(aa '
\(ap ~
\(br |
\(bu + (prints a warning)
\(bv |
\(ci O
\(dd *** (prints a warning)
\(dg ** (prints a warning)
\(em --
\(en -
\(eq =
\(ff ff
\(fi fi
\(fl fl
\(fm '
\(ga `
\(lh &lt;=
\(lq ``
\(mi -
\(or |
\(pl +
\(rh =&gt;
\(rq ''
\(ru _
\(sl /
\(sq o (prints a warning)
\(ul _
\(~= ~
</pre>
<p>
A warning is printed to standard error output for any special
character not mentioned in this section.<tt> </tt>
To add new definitions, and to customize existing ones, the
<i>defspecial
</i>Scheme primitive can be used.<tt> </tt>
<h3>NON-FILLED TEXT</h3>
The
<b>.nf
</b>and
<b>.fi
</b>troff requests generate pairs of &lt;pre&gt; and &lt;/pre&gt; tags.<tt> </tt>
Nested requests are treated correctly, and currently
active character formatting elements such as &lt;i&gt; (resulting
from troff font changes) are temporarily disabled while
the &lt;pre&gt; or &lt;/pre&gt; is emitted.<tt> </tt>
A warning is printed if a ``tab'' character is encountered
within filled text.<tt> </tt>
<h3>FONTS</h3>
The `\f' escape sequence and the requests
<b>.ft
</b>(change current font) and
<b>.fp
</b>(mount font at font position) are supported in the usual way,
both with numeric font positions as well as font names and
the special name `P' to denote the previous font.<tt> </tt>
The font position of the currently active font is available
through the read-only number register `.f'.<tt> </tt>
Initially, the font `R' is mounted on font positions 1 and 4,
font `I' on font position 2, and font `B' on position 3.<tt> </tt>
<p>
To map troff font names to HTML character formatting elements,
the <i>define-font</i> Scheme procedure is called with the name
of a troff font to be used in documents, and
HTML start and end tags to be emitted when changing to this font,
or when changing
<i>from
</i>this font to another font, respectively.<tt> </tt>
Whether &lt;tt&gt; and &lt;/tt&gt; is generated inside non-filled (pre-formatted)
text for fixed-width fonts is controlled by the option
<b>tt-preformat</b>.<tt> </tt>
The following calls to
<i>define-font
</i>are evaluated on startup:
<p>
<pre>
(define-font "R" "" "")
(define-font "I" '&lt;i&gt; '&lt;/i&gt;)
(define-font "B" '&lt;b&gt; '&lt;/b&gt;)
(define-font "C" '&lt;tt&gt; '&lt;/tt&gt;)
(define-font "CW" '&lt;tt&gt; '&lt;/tt&gt;)
(define-font "CO" '&lt;i&gt; '&lt;/i&gt;) ; kludge for Courier-Oblique
</pre>
<p>
Site administrators may add definitions here for fonts used
at their site.<tt> </tt>
Users can define mappings for new fonts by placing corresponding
definitions in their documents or document-specific Scheme files.<tt> </tt>
<h3>OTHER TROFF REQUESTS</h3>
The
<b>.br
</b>request generates a &lt;br&gt; tag.<tt> </tt>
<p>
<b>.sp
</b>requires a positive argument and is mapped to the appropriate number
of &lt;p&gt; tags (or newline characters inside non-filled/pre-formatted
text).<tt> </tt>
Likewise, the request
<b>.ti</b>,
when called with a positive indent, produces a &lt;br&gt; followed by the
appropriate number of non-breakable spaces.<tt> </tt>
<p>
The
<b>.tl
</b>requests justs emits the title parts delimited by spaces.<tt> </tt>
It is impossible to preserve the meaning of this request
in HTML 2.0.<tt> </tt>
<p>
The horizontal line drawing escape sequence `\l' just repeats
the specified character (or underline as default) to draw
a line.<tt> </tt>
If the given length looks like it could be the line length
(that is, if it exceeds a certain value), a &lt;hr&gt; tag
is produced instead.<tt> </tt>
Example:
<p>
<pre>
\l'5c\&amp;-'
\l'60'
</pre>
<p>
The first of these two requests
would produce a line of 20 dashes, while the second
request would generate a &lt;hr&gt; tag (the '\&amp;' is required
because the dash could be interpreted as a continuation of
the numeric expression).<tt> </tt>
<p>
Centering
(<b>.ce</b>)
is simulated by producing a &lt;br&gt; at the end of each line, as
this functionality is not supported by HTML 2.0.<tt> </tt>
<p>
The following requests are silently ignored; as the corresponding
functions cannot be expressed in HTML 2.0 or are controlled by
the client.<tt> </tt>
Ignoring these requests most likely does no harm.<tt> </tt>
<p>
<pre>
.ad .bp .ch .fl .hw .hy .lg
.na .ne .nh .ns .pl .ps .rs
.vs .wh
</pre>
<p>
All troff requests not mentioned in this section by default
cause a warning message to be printed to standard error output,
except for these basic requests which have their usual
semantics:
<p>
<pre>
.am .as .de .ds .ec .el .ie
.if .ig .nr .rm .rr .so .tm
</pre>
<p>
The
<i>defrequest
</i>Scheme primitive is used to associate an event handling procedure
with a request as documented in the Programmer's Manual.<tt> </tt>
<h3>END OF SENTENCE</h3>
The sequence ``&lt;tt&gt;space&lt;/tt&gt;'' is produced at the end of
each sentence to provide additional space, except inside non-filled text.<tt> </tt>
A sentence is defined a sequence of characters followed by
a period, a question mark, or an exclamation mark, followed
by a newline.<tt> </tt>
The usual convention to suppress end-of-sentence recognition
by adding the escape sequence `\&amp;' is correctly implemented by
<i>unroff</i>.<tt> </tt>
To change the end-of-sentence function, the
<i>sentence-event
</i>can be redefined from within Scheme code as described in
the Programmer's Manual.<tt> </tt>
<h3>SCALE INDICATORS</h3>
As the notions of vertical spacing, character width, device
resolution, etc. do not exist in HTML, the scaling for the
usual troff scale indicators is defined once on startup and
then remains constant.<tt> </tt>
For simplicity, the scaling usually employed by
<b>nroff</b>(1)
is taken.<tt> </tt>
<h3>EQUATIONS, TABLES, PICTURES</h3>
Interpretation of embedded eqn, tbl, and pic preprocessor input
is controlled by the options
<b>handle-eqn</b>,
<b>handle-tbl</b>,
and
<b>handle-pic
</b>(see OPTIONS above).<tt> </tt>
These options affect the input lines from a starting
<b>.EQ</b>,
<b>.TS</b>,
or
<b>.PS
</b>request up to and including the matching
<b>.EN</b>,
<b>.TE</b>,
or
<b>.PE
</b>request, as well as text surrounded by the current eqn
inline equation delimiters.<tt> </tt>
Each of the options can have one the following values:
<dl>
<dt><b>copy
</b><dd>
The preprocessor input (including the enclosing requests) is
placed inside &lt;pre&gt; and &lt;/pre&gt;.<tt> </tt>
If assigned to the option
<b>handle-eqn</b>,
inline equations are rendered in the font currently mounted
on font position 2.<tt> </tt>
<dt><b>text
</b><dd>
The input is sent to the respective preprocessor (as specified
by the options
<b>eqn</b>,
<b>tbl</b>,
or
<b>pic</b>),
and its result is piped to the shell command referred to by the
option
<b>troff-to-text</b>,
which typically involves a call to
<b>nroff</b>(1)
or an equivalent command.<tt> </tt>
As with ``copy'', the result is then placed inside
&lt;pre&gt; and &lt;/pre&gt;, unless the source is an inline equation.<tt> </tt>
<dt><dd><p>
The value of
<b>troff-to-text
</b>is filtered through a call to the
<i>substitute
</i>Scheme primitive with the name of an output file as its argument;
this file name can be referenced from within the option's value
by the substitute specifier ``%1%'' (see the Programmer's
Manual for a description of
<i>substitute
</i>and a list of substitute specifiers).<tt> </tt>
Here is a typical value for the
<b>troff-to-text
</b>option:
</dl>
<dl><dt><dd>
<pre>
"groff -Tascii | col -b | sed '/^[ \t]*$/d' &gt; %1%"
</pre>
</dl>
<dl>
<dt><b>gif
</b><dd>
Input lines are preprocessed as described under ``text'', and
the result is piped to the shell command named by the option
<b>troff-to-gif</b>.<tt> </tt>
The latter is subject to a call to
<i>substitute
</i>with the name of a temporary file (which may be used to store intermediate
PostScript output) and the name of the output file where the resulting
GIF image must be stored.<tt> </tt>
The entire preprocessor input is replaced by an &lt;img&gt; element with
a reference to the GIF file and a suitable ``alt='' attribute.<tt> </tt>
Unless processing an inline equation, the &lt;img&gt; element is
surrounded by &lt;p&gt; tags.<tt> </tt>
<dt><dd><p>
The names of the files containing the GIF images are generated
from the value of the
<b>document
</b>option, a sequence number, and the suffix ``.gif''.<tt> </tt>
Therefore, the
<b>document
</b>option must have been set when using the ``gif'' method,
otherwise a warning is printed and the preprocessor input
is skipped.<tt> </tt>
</dl>
<p>
In any case, the output of a call to eqn is ignored if the
input consists of calls to ``delim'' or ``define''
and empty lines exclusively.<tt> </tt>
When processing eqn input, calls to ``delim'' are intercepted by
<i>unroff
</i>to record changes of the inline equation delimiters.<tt> </tt>
<h3>HYPERTEXT LINKS</h3>
The facilities for embedding arbitrary hypertext links in troff
documents are still experimental in this version of
<i>unroff
</i>and thus are likely to change in future releases.<tt> </tt>
To use them, mention the file name ``hyper.scm'' in the
command line before any troff source files.<tt> </tt>
At the beginning of the first troff file, source the file
``tmac.hyper'' from the directory ``doc'' like this:
<p>
<pre>
.if !\n(.U .so tmac.hyper
</pre>
<p>
The request
<b>.Hr
</b>can then be used to create a hypertext link.<tt> </tt>
Its usage is:
<p>
<pre>
.Hr -url URL anchor-text [suffix]
.Hr -symbolic label anchor-text [suffix]
.Hr troff-text
</pre>
<p>
The first two forms are recognized by
<i>unroff
</i>and the third form is recognized by troff.<tt> </tt>
The first form is used for links pointing to external resources,
and the second one is used for forward or backward links referencing
anchors defined in a file belonging to the same document.<tt> </tt>
An anchor is placed in the document by calling the request
<b>.Ha</b>:
<p>
<pre>
.Ha label anchor-text
</pre>
<p>
The label specified in a call to
<b>.Ha
</b>can then be used in calls to
<b>.Hr -symbolic</b>.<tt> </tt>
All symbolic references must have been resolved at the end of the document.<tt> </tt>
The ``anchor-text'' is placed between the tags &lt;a&gt; and &lt;/a&gt;;
``suffix'' is appended to the closing &lt;/a&gt; if present.<tt> </tt>
``troff-text'' is just formatted in the normal way.<tt> </tt>
Quotes must be used if any of the arguments contains spaces.<tt> </tt>
<p>
Use of the hypertext facilities is demonstrated by the troff source
of the Programmer's Manual that is included in the
<i>unroff
</i>distribution.<tt> </tt>
<h2>SCHEME PROCEDURES</h2>
The following Scheme procedures, macros, and variables are defined
by the HTML 2.0 back-end and can be used from within user-supplied
Scheme code:
<dl>
<dt>(<i>define-font name start-tag end-tag</i>)
<dd>
Associates a HTML start tag and end tag (symbols) with a troff
font name (string) as explained under FONTS above.<tt> </tt>
The font name can then be used in
<b>.fp</b>,
<b>.ft</b>,
and `\f' requests.<tt> </tt>
<dt>(<i>reset-font</i>)
<dd>
Resets both the current and previous font to the font mounted
on position 1.<tt> </tt>
<dt><i>current-font</i>
<dd>
<dt><i>previous-font</i>
<dd>
These variables hold the current and previous font as
(integer) font positions.<tt> </tt>
<dt>(<i>with-font-preserved</i> . <i>body</i>)
<dd>
This macro can be used to temporarily change to font ``R'',
evaluate <i>body</i>, and revert to the font that has been
active when the form was entered.<tt> </tt>
The macro returns a string that can be output using the
primitive <i>emit</i> or returned from an event procedure.<tt> </tt>
<dt>(<i>preform enable?</i>)
<dd>
If the argument is #t, pre-formatted text is enabled, otherwise disabled.<tt> </tt>
<dt><i>preform?</i>
<dd>
This boolean variable holds #t if pre-formatted text is enabled,
#f otherwise.<tt> </tt>
<dt>(<i>with-preform-preserved</i> . <i>body</i>)
<dd>
A macro that can be used to temporarily disable pre-formatted
text, evaluate <i>body</i>, and then re-enable it if appropriate.<tt> </tt>
The macro expands to a string that must be output or returned from
an event procedure.<tt> </tt>
<dt>(<i>parse-unquote string</i>)
<dd>
Temporarily establishes an output translation to map the quote
character to ``&amp;quot;'', applies <i>parse</i> (explained
in the Programmer's Manual) to its argument, and returns the result.<tt> </tt>
<dt>(<i>center n</i>)
<dd>
Centers the next <i>n</i> input lines (see description of
<b>.ce
</b>under TROFF REQUESTS above).<tt> </tt>
If <i>n</i> is zero, centering is stopped.<tt> </tt>
<dt><i>nbsp</i>
<dd>
A Scheme variable that holds a string interpreted as a non-breaking
space by HTML clients.<tt> </tt>
</dl>
<h2>SEE ALSO</h2>
<b>unroff</b>(1),
<b>unroff-html-man</b>(1),
<b>unroff-html-ms</b>(1);
<br>
<b>troff</b>(1),
<b>nroff</b>(1),
<b>groff</b>(1),
<b>eqn</b>(1),
<b>tbl</b>(1),
<b>pic</b>(1).<tt> </tt>
<p>
Unroff Programmer's Manual.<tt> </tt>
<p>
http://www.informatik.uni-bremen.de/~net/unroff
<p>
Berners-Lee, Connolly, et al.,
HyperText Markup Language Specification--2.0,
Internet Draft, Internet Engineering Task Force.<tt> </tt>
<h2>BUGS</h2>
The `\space' escape sequence should be mapped to the &amp;#160; entity
(non-breaking space), but this entity is not supported by a number
of HTML clients.<tt> </tt>
<p>
Only the font positions 1 to 9 can currently be used.<tt> </tt>
There should be no limit.<tt> </tt>
<p>
The extra space generated for end of sentence should be configurable.<tt> </tt>
<p>
Underlining should be supported.<tt> </tt>
<p><hr>
Markup created by <em>unroff</em> 1.0,&#160;<tt> </tt>&#160;<tt> </tt>March 21, 1996.
</body>
</html>