MANDOC(1) FreeBSD General Commands Manual MANDOC(1)
NAME
mandoc -- format and display UNIX manuals
SYNOPSIS
mandoc [-foption...] [-mformat] [-ooption...] [-Toutput] [-V] [-Werr...]
[infile...]
DESCRIPTION
The mandoc utility formats UNIX manual pages for display. The arguments
are as follows:
-foption...
Comma-separated compiler options. See Compiler Options for
details.
-mformat
Input format. See Input Formats for available formats. Defaults
to -mandoc.
-oformat
Comma-separated output options. See Output Options for details.
-Toutput
Output format. See Output Formats for available formats.
Defaults to -Tascii.
-V Print version and exit.
-Werr...
Comma-separated warning options. Use -Wall to print warnings,
-Werror for warnings to be considered errors and cause utility
termination. Multiple -W arguments may be comma-separated, such
as -Werror,all.
infile...
Read input from zero or more infile. If unspecified, reads from
stdin. If multiple files are specified, mandoc will halt with
the first failed parse.
By default, mandoc reads mdoc(7) or man(7) text from stdin, implying
-mandoc, and prints 78-column backspace-encoded output to stdout as if
-Tascii were provided.
The mandoc utility exits 0 on success, and >0 if an error occurs.
Punctuation and Spacing
If punctuation is set apart from words, such as in the phrase ``to be ,
or not to be'', it's processed by mandoc according to the following
rules: opening punctuation (`(', `[', and `{') is not followed by a
space; closing punctuation (`.', `,', `;', `:', `?', `!', `)', `]' and
`}') is not preceded by whitespace.
If the input is mdoc(7), these rules are also applied to macro arguments
when appropriate.
White-space, in non-literal (normal) mode, is stripped from input and
replaced on output by a single space. Thus, if you wish to preserve mul-
tiple spaces, they must be space-escaped or used in a literal display
mode, e.g., `Bd -literal' in mdoc(7).
Input Formats
The mandoc utility accepts mdoc(7) and man(7) input with -mdoc and -man,
respectively. The mdoc(7) format is strongly recommended; man(7) should
only be used for legacy manuals.
A third option, -mandoc, which is also the default, determines encoding
on-the-fly: if the first non-comment macro is `Dd' or `Dt', the mdoc(7)
parser is used; otherwise, the man(7) parser is used.
If multiple files are specified with -mandoc, each has its file-type
determined this way. If multiple files are specified and -mdoc or -man
is specified, then this format is used exclusively.
Output Formats
The mandoc utility accepts the following -T arguments:
-Tascii
Produce 7-bit ASCII output, backspace-encoded for bold and under-
line styles. This is the default.
-Thtml Produce strict HTML-4.01 output, with a sane default style.
-Ttree Produce an indented parse tree.
-Tlint Parse only: produce no output.
If multiple input files are specified, these will be processed by the
corresponding filter in-order.
Compiler Options
Default compiler behaviour may be overridden with the -f flag.
-fign-scope
When rewinding the scope of a block macro, forces the compiler to
ignore scope violations. This can seriously mangle the resulting
tree. (mdoc only)
-fno-ign-escape
Don't ignore invalid escape sequences.
-fno-ign-macro
Do not ignore unknown macros at the start of input lines.
-fno-ign-chars
Do not ignore disallowed characters.
-fstrict
Implies -fno-ign-escape, -fno-ign-macro and -fno-ign-chars.
-fign-errors
Don't halt when encountering parse errors. Useful with -Tlint
over a large set of manuals passed on the command line.
Output Options
For the time being, only -Thtml is the only mode with output options:
-ostyle=style.css
The file style.css is used for an external style-sheet. This
must be a valid absolute or relative URI.
-obase=http://base/
The URL http://base/ is used as a base URL for all relative
links. This is useful when linking between documents via the
`Xr' macro.
EXAMPLES
To page manuals to the terminal:
% mandoc -Wall,error -fstrict mandoc.1 2>&1 | less
% mandoc mandoc.1 mdoc.3 mdoc.7 | less
To produce HTML manuals with http://localhost/ as the base URI:
% mandoc -Thtml -obase=http://localhost/ mdoc.7 > mdoc.7.html
To check over a large set of manuals:
% mandoc -Tlint -fign-errors `find /usr/src -name \*\.[1-9]`
COMPATIBILITY
This section summarises mandoc compatibility with groff(1). Each input
and output format is separately noted.
ASCII output
o The `\~' special character doesn't produce expected behaviour in
-Tascii.
o The `Bd -literal' and `Bd -unfilled' macros of mdoc(7) in -Tascii are
synonyms, as are -filled and -ragged.
o In groff(1), the `Pa' mdoc(7) macro does not underline when scoped
under an `It' in the FILES section. This behaves correctly in
mandoc.
o A list or display following `Ss' mdoc(7) macro in -Tascii does not
assert a prior vertical break, just as it doesn't with `Sh'.
o The `na' man(7) macro in -Tascii has no effect.
o Words aren't hyphenated.
o In normal mode (not a literal block), blocks of spaces aren't pre-
served, so double spaces following sentence closure are reduced to a
single space; groff(1) retains spaces.
o Sentences are unilaterally monospaced.
SEE ALSO
mandoc_char(7), mdoc(7), man(7)
AUTHORS
The mandoc utility was written by Kristaps Dzonsons <kristaps@kth.se>.
FreeBSD 7.2 February 4, 2010 FreeBSD 7.2
NAME - SYNOPSIS - DESCRIPTION - EXAMPLES - COMPATIBILITY - SEE ALSO -
AUTHORS -
|