mandoc

Package: WA2L/WinTools 1.2.08
Section: Misc. Reference Manual Pages (1 )
Index Return to Main Contents

BSD mandoc
 

NAME

mandoc - format and display UNIX manuals  

SYNOPSIS

mandoc [-V ] [-I os = name ] [-m format ] [-O option ] [-T output ] [-W level ] [ ]  

DESCRIPTION

The utility formats UNIX manual pages for display.

By default, reads mdoc(7) or man(7) text from stdin, implying -m andoc , and produces -T ascii output.

The arguments are as follows:

-I os = name
Override the default operating system name for the mdoc(7) ` ' macro.
-m format
Input format. See Sx Input Formats for available formats. Defaults to -m andoc .
-O option
Comma-separated output options.
-T output
Output format. See Sx Output Formats for available formats. Defaults to -T ascii .
-V
Print version and exit.
-W level
Specify the minimum message level to be reported on the standard error output and to affect the exit status. The level can be warning , error , or fatal . The default is -W fatal ; -W all is an alias for -W warning . See Sx EXIT STATUS and Sx DIAGNOSTICS for details.

The special option -W stop tells to exit after parsing a file that causes warnings or errors of at least the requested level. No formatted output will be produced from that file. If both a level and stop are requested, they can be joined with a comma, for example -W error , stop .

file
Read input from zero or more files. If unspecified, reads from stdin. If multiple files are specified, will halt with the first failed parse.

 

Input Formats

The utility accepts mdoc(7) and man(7) input with -m doc and -m an , respectively. The mdoc(7) format is strongly recommended; man(7) should only be used for legacy manuals.

A third option, -m andoc , which is also the default, determines encoding on-the-fly: if the first non-comment macro is ` ' or ` ' the mdoc(7) parser is used; otherwise, the man(7) parser is used.

If multiple files are specified with -m andoc , each has its file-type determined this way. If multiple files are specified and -m doc or -m an is specified, then this format is used exclusively.  

Output Formats

The utility accepts the following -T arguments, which correspond to output modes:

-T ascii
Produce 7-bit ASCII output. This is the default. See Sx ASCII Output .
-T html
Produce strict CSS1/HTML-4.01 output. See Sx HTML Output .
-T lint
Parse only: produce no output. Implies -W warning .
-T locale
Encode output using the current locale. See Sx Locale Output .
-T man
Produce man(7) format output. See Sx Man Output .
-T pdf
Produce PDF output. See Sx PDF Output .
-T ps
Produce PostScript output. See Sx PostScript Output .
-T tree
Produce an indented parse tree.
-T utf8
Encode output in the UTF-8 multi-byte format. See Sx UTF-8 Output .
-T xhtml
Produce strict CSS1/XHTML-1.0 output. See Sx XHTML Output .

If multiple input files are specified, these will be processed by the corresponding filter in-order.  

ASCII Output

Output produced by -T ascii , which is the default, is rendered in standard 7-bit ASCII documented in ascii(7).

Font styles are applied by using back-spaced encoding such that an underlined character `c' is rendered as `_ \[bs] c , ' where `\[bs]' is the back-space character number 8. Emboldened characters are rendered as `c \[bs] c . '

The special characters documented in mandoc_char7 are rendered best-effort in an ASCII equivalent. If no equivalent is found, `?' is used instead.

Output width is limited to 78 visible columns unless literal input lines exceed this limit.

The following -O arguments are accepted:

indent = indent
The left margin for normal text is set to indent blank characters instead of the default of five for mdoc(7) and seven for man(7). Increasing this is not recommended; it may result in degraded formatting, for example overfull lines or ugly line breaks.
width = width
The output width is set to width , which will normalise to >60.

 

HTML Output

Output produced by -T html conforms to HTML-4.01 strict.

The example.style.css file documents style-sheet classes available for customising output. If a style-sheet is not specified with -O style , -T html defaults to simple output readable in any graphical or text-based web browser.

Special characters are rendered in decimal-encoded UTF-8.

The following -O arguments are accepted:

fragment
Omit the Aq !DOCTYPE declaration and the Aq html , Aq head , and Aq body elements and only emit the subtree below the Aq body element. The style argument will be ignored. This is useful when embedding manual content within existing documents.
includes = fmt
The string fmt , for example, ../src/%I.html , is used as a template for linked header files (usually via the `In ' macro). Instances of `%I' are replaced with the include filename. The default is not to present a hyperlink.
man = fmt
The string fmt , for example, ../html%S/%N.%S.html , is used as a template for linked manuals (usually via the ` ' macro). Instances of `%N' and `%S' are replaced with the linked manual's name and section, respectively. If no section is included, section 1 is assumed. The default is not to present a hyperlink.
style = style.css
The file style.css is used for an external style-sheet. This must be a valid absolute or relative URI.

 

Locale Output

Locale-depending output encoding is triggered with -T locale . This option is not available on all systems: systems without locale support, or those whose internal representation is not natively UCS-4, will fall back to -T ascii . See Sx ASCII Output for font style specification and available command-line arguments.  

Man Output

Translate input format into man(7) output format. This is useful for distributing manual sources to legacy systems lacking mdoc(7) formatters.

If mdoc(7) is passed as input, it is translated into man(7). If the input format is man(7), the input is copied to the output, expanding any roff(7) `so' requests. The parser is also run, and as usual, the -W level controls which Sx DIAGNOSTICS are displayed before copying the input to the output.  

PDF Output

PDF-1.1 output may be generated by -T pdf . See Sx PostScript Output for -O arguments and defaults.  

PostScript Output

PostScript Qq Adobe-3.0 Level-2 pages may be generated by -T ps . Output pages default to letter sized and are rendered in the Times font family, 11-point. Margins are calculated as 1/9 the page length and width. Line-height is 1.4m.

Special characters are rendered as in Sx ASCII Output .

The following -O arguments are accepted:

paper = name
The paper size name may be one of a3 , a4 , a5 , legal , or letter . You may also manually specify dimensions as NNxNN , width by height in millimetres. If an unknown value is encountered, letter is used.

 

UTF-8 Output

Use -T utf8 to force a UTF-8 locale. See Sx Locale Output for details and options.  

XHTML Output

Output produced by -T xhtml conforms to XHTML-1.0 strict.

See Sx HTML Output for details; beyond generating XHTML tags instead of HTML tags, these output modes are identical.  

EXIT STATUS

The utility exits with one of the following values, controlled by the message level associated with the -W option:

0
No warnings or errors occurred, or those that did were ignored because they were lower than the requested level .
2
At least one warning occurred, but no error, and -W warning was specified.
3
At least one parsing error occurred, but no fatal error, and -W error or -W warning was specified.
4
A fatal parsing error occurred.
5
Invalid command line arguments were specified. No input files have been read.
6
An operating system error occurred, for example memory exhaustion or an error accessing input files. Such errors cause to exit at once, possibly in the middle of parsing or formatting a file.

Note that selecting -T lint output mode implies -W warning .  

EXAMPLES

To page manuals to the terminal:

$ mandoc -Wall,stop mandoc.1 2&1 | less
$ mandoc mandoc.1 mdoc.3 mdoc.7 | less

To produce HTML manuals with style.css as the style-sheet:

$ mandoc -Thtml -Ostyle=style.css mdoc.7 mdoc.7.html

To check over a large set of manuals:

$ mandoc -Tlint `find /usr/src -name \*\.[1-9]`

To produce a series of PostScript manuals for A4 paper:

$ mandoc -Tps -Opaper=a4 mdoc.7 man.7 manuals.ps

Convert a modern mdoc(7) manual to the older man(7) format, for use on systems lacking an mdoc(7) parser:

$ mandoc -Tman foo.mdoc foo.man
 

DIAGNOSTICS

Messages displayed by follow this format:

Line and column numbers start at 1. Both are omitted for messages referring to an input file as a whole. Macro names and arguments are omitted where meaningless. Fatal messages about invalid command line arguments or operating system errors, for example when memory is exhausted, may also omit the file and level fields.

Message levels have the following meanings:

syserr
Opening or reading an input file failed, so the parser cannot even be started and no output is produced from that input file.
fatal
The parser is unable to parse a given input file at all. No formatted output is produced from that input file.
error
An input file contains syntax that cannot be safely interpreted, either because it is invalid or because does not implement it yet. By discarding part of the input or inserting missing tokens, the parser is able to continue, and the error does not prevent generation of formatted output, but typically, preparing that output involves information loss, broken document structure or unintended formatting.
warning
An input file uses obsolete, discouraged or non-portable syntax. All the same, the meaning of the input is unambiguous and a correct rendering can be produced. Documents causing warnings may render poorly when using other formatting tools instead of .

Messages of the warning and error levels are hidden unless their level, or a lower level, is requested using a -W option or -T lint output mode.  

Warnings related to the document prologue

missing manual title, using UNTITLED
(mdoc) A macro has no arguments, or there is no macro before the first non-prologue macro.
missing manual title, using dqdq
(man) There is no TH macro, or it has no arguments.
lower case character in document title
(mdoc , man) The title is still used as given in the or TH macro.
missing manual section, using dqdq
(mdoc , man) A or TH macro lacks the mandatory section argument.
unknown manual section
(mdoc) The section number in a line is invalid, but still used.
unknown manual volume or arch
(mdoc) The volume name in a line is invalid, but still used. The manual is assumed to be architecture-independent.
missing date, using today's date
(mdoc, man) The document was parsed as mdoc(7) and it has no macro, or the macro has no arguments or only empty arguments; or the document was parsed as man(7) and it has no TH macro, or the TH macro has less than three arguments or its third argument is empty.
cannot parse date, using it verbatim
(mdoc , man) The date given in a or TH macro does not follow the conventional format.
missing macro, using dqdq
(mdoc) The default or current system is not shown in this case.
duplicate prologue macro
(mdoc) One of the prologue macros occurs more than once. The last instance overrides all previous ones.
late prologue macro
(mdoc) A or macro occurs after some non-prologue macro, but still takes effect.
skipping late title macro
(mdoc) The macro can only occur before the first non-prologue macro because traditional formatters write the page header before parsing the document body. Even though this technical restriction does not apply to , traditional semantics is preserved. The late macro is discarded including its arguments.
prologue macros out of order
(mdoc) The prologue macros are not given in the conventional order , . All three macros are used even when given in another order.

 

Warnings regarding document structure

.so is fragile, better use ln(1)
(roff) Including files only works when the parser program runs with the correct current working directory.
no document body
(mdoc , man) The document body contains neither text nor macros. An empty document is shown, consisting only of a header and a footer line.
content before first section header
(mdoc , man) Some macros or text precede the first
 

or SH section header. The offending macros and text are parsed and added to the top level of the syntax tree, outside any section block. Sy "first section is not NAME" (mdoc) The argument of the first  

macro is not `NAME .' This may confuse makewhatis(8) and apropos(1). Sy "bad NAME section contents" (mdoc) The last node in the NAME section is not an - macro, or any preceding macro is not , or the NAME section is completely empty. This may confuse makewhatis(8) and apropos(1). Sy "sections out of conventional order" (mdoc) A standard section occurs after another section it usually precedes. All section titles are used as given, and the order of sections is not changed. Sy "duplicate section title" (mdoc) The same standard section title occurs more than once. Sy "unexpected section" (mdoc) A standard section header occurs in a section of the manual where it normally isn't useful.

 

Warnings related to macros and nesting

obsolete macro
(mdoc) See the mdoc(7) manual for replacements.
skipping paragraph macro
In mdoc(7) documents, this happens

at the beginning and end of sections and subsections
right before non-compact lists and displays
at the end of items in non-column, non-compact lists
and for multiple consecutive paragraph macros.

In man(7) documents, it happens

for empty P , PP , and LP macros
for IP macros having neither head nor body arguments
for br or sp right after SH or SS

moving paragraph macro out of list
(mdoc) A list item in a

list contains a trailing paragraph macro. The paragraph macro is moved after the end of the list.

skipping no-space macro
(mdoc) An input line begins with an macro. The macro is ignored.
blocks badly nested
(mdoc) If two blocks intersect, one should completely contain the other. Otherwise, rendered output is likely to look strange in any output format, and rendering in SGML-based output formats is likely to be outright wrong because such languages do not support badly nested blocks at all. Typical examples of badly nested blocks are Qq Ic Ao Bo Ac Bc and Qq Ic Ao Bq Ac . In these examples, Ac breaks Bo and Bq , respectively.
nested displays are not portable
(mdoc) A D1 , or
display occurs nested inside another display. This works with , but fails with most other implementations.
moving content out of list
(mdoc) A

list block contains text or macros before the first

macro. The offending children are moved before the beginning of the list.
.Vt block has child macro
(mdoc) The Vt macro supports plain text arguments only. Formatting may be ugly and semantic searching for the affected content might not work.
fill mode already enabled, skipping
(man) A fi request occurs even though the document is still in fill mode, or already switched back to fill mode. It has no effect.
fill mode already disabled, skipping
(man) An nf request occurs even though the document already switched to no-fill mode and did not switch back to fill mode yet. It has no effect.
line scope broken
(man) While parsing the next-line scope of the previous macro, another macro is found that prematurely terminates the previous one. The previous, interrupted macro is deleted from the parse tree.

 

Warnings related to missing arguments

skipping empty request
(roff) The macro name is missing from a macro definition request.
conditional request controls empty scope
(roff) A conditional request is only useful if any of the following follows it on the same logical input line:

The `\{' keyword to open a multi-line scope.
A request or macro or some text, resulting in a single-line scope.
The immediate end of the logical line without any intervening whitespace, resulting in next-line scope.

Here, a conditional request is followed by trailing whitespace only, and there is no other content on its logical input line. Note that it doesn't matter whether the logical input line is split across multiple physical input lines using `\' line continuation characters. This is one of the rare cases where trailing whitespace is syntactically significant. The conditional request controls a scope containing whitespace only, so it is unlikely to have a significant effect, except that it may control a following el clause.

skipping empty macro
(mdoc) The indicated macro has no arguments and hence no effect.
empty argument, using 0n
(mdoc) The required width is missing after or

-offset or -width.

argument count wrong
(mdoc , man) The indicated macro has too few or too many arguments. The syntax tree will contain the wrong number of arguments as given. Formatting behaviour depends on the specific macro in question. Note that the same message may also occur as an ERROR, see below.
missing display type, using -ragged
(mdoc) The macro is invoked without the required display type.
list type is not the first argument
(mdoc) In a

macro, at least one other argument precedes the type argument. The utility copes with any argument order, but some other mdoc(7) implementations do not.

missing -width in -tag list, using 8n
(mdoc) Every

macro having the -tag argument requires -width , too.

missing utility name, using dqdq
(mdoc) The Ex -std macro is called without an argument before has first been called with an argument.
empty head in list item
(mdoc) In a

-diag , -hang , -inset , -ohang , or -tag list, an

macro lacks the required argument. The item head is left empty.
empty list item
(mdoc) In a

-bullet , -dash , -enum , or -hyphen list, an

block is empty. An empty list item is shown.
missing font type
(mdoc) A Bf macro has no argument. It switches to the default font, \fR .
unknown font type
(mdoc) The Bf argument is invalid. The default font \fR is used instead.
missing -std argument, adding it
(mdoc) An Ex or Rv macro lacks the required -std argument. The utility assumes -std even when it is not specified, but other implementations may not.

 

Warnings related to bad macro arguments

unterminated quoted argument
(roff) Macro arguments can be enclosed in double quote characters such that space characters and macro names contained in the quoted argument need not be escaped. The closing quote of the last argument of a macro can be omitted. However, omitting it is not recommended because it makes the code harder to read.
duplicate argument
(mdoc) A or

macro has more than one -compact , more than one -offset , or more than one -width argument. All but the last instances of these arguments are ignored.

skipping duplicate argument
(mdoc) An An macro has more than one -split or -nosplit argument. All but the first of these arguments are ignored.
skipping duplicate display type
(mdoc) A macro has more than one type argument; the first one is used.
skipping duplicate list type
(mdoc) A

macro has more than one type argument; the first one is used.

skipping -width argument
(mdoc) A

-column , -diag , -ohang , -inset , or -item list has a -width argument. That has no effect.

unknown AT&T UNIX version
(mdoc) An AT&T System macro has an invalid argument. It is used verbatim, with Qq AT&T UNIX prefixed to it.
invalid content in
(mdoc) An
block contains plain text or non-% macros. The bogus content is left in the syntax tree. Formatting may be poor. Sy "invalid Boolean argument" (mdoc) An macro has an argument other than on or off . The invalid argument is moved out of the macro, which leaves the macro empty, causing it to toggle the spacing mode. Sy "unknown font, skipping request" (man) A roff(7) ft request has an invalid argument.

 

Warnings related to plain text

blank line in fill mode, using .sp
(mdoc) The meaning of blank input lines is only well-defined in non-fill mode: In fill mode, line breaks of text input lines are not supposed to be significant. However, for compatibility with groff, blank lines in fill mode are replaced with sp requests.
tab in filled text
(mdoc , man) The meaning of tab characters is only well-defined in non-fill mode: In fill mode, whitespace is not supposed to be significant on text input lines. As an implementation dependent choice, tab characters on text lines are passed through to the formatters in any case. Given that the text before the tab character will be filled, it is hard to predict which tab stop position the tab will advance to.
whitespace at end of input line
(mdoc , man , roff) Whitespace at the end of input lines is almost never semantically significant --- but in the odd case where it might be, it is extremely confusing when reviewing and maintaining documents.
bad comment style
(roff) Comment lines start with a dot, a backslash, and a double-quote character. The utility treats the line as a comment line even without the backslash, but leaving out the backslash might not be portable.
invalid escape sequence
(roff) An escape sequence has an invalid opening argument delimiter, lacks the closing argument delimiter, or the argument has too few characters. If the argument is incomplete, \* and \n expand to an empty string, \B to the digit `0 ,' and \w to the length of the incomplete argument. All other invalid escape sequences are ignored.
undefined string, using dqdq
(roff) If a string is used without being defined before, its value is implicitly set to the empty string. However, defining strings explicitly before use keeps the code more readable.

 

Errors related to equations

"unexpected equation scope closure"
"equation scope open on exit"
"overlapping equation scopes"
"unexpected end of equation"
"equation syntax error"

 

Errors related to tables

"bad table syntax"
"bad table option"
"bad table layout"
"no table layout cells specified"
"no table data cells specified"
"ignore data in cell"
"data block still open"
"ignoring extra data cells"

 

Errors related to roff, mdoc, and man code

input stack limit exceeded, infinite loop?
(roff) Explicit recursion limits are implemented for the following features, in order to prevent infinite loops:

expansion of nested escape sequences including expansion of strings and number registers,
expansion of nested user-defined macros,
and so file inclusion.

When a limit is hit, the output is incorrect, typically losing some content, but the parser can continue.

skipping bad character
(mdoc , man , roff) The input file contains a byte that is not a printable ascii(7) character. The message mentions the character number. The offending byte is replaced with a question mark (`? .' ) Consider editing the input file to replace the byte with an ASCII transliteration of the intended character.
skipping unknown macro
(mdoc , man , roff) The first identifier on a request or macro line is neither recognized as a roff(7) request, nor as a user-defined macro, nor, respectively, as an mdoc(7) or man(7) macro. It may be mistyped or unsupported. The request or macro is discarded including its arguments.
skipping item outside list
(mdoc) An
macro occurs outside any

list. It is discarded including its arguments.

skipping column outside column list
(mdoc) A Ta macro occurs outside any

block. It is discarded including its arguments.

skipping end of block that is not open
(mdoc , man , eqn , tbl , roff) Various syntax elements can only be used to explicitly close blocks that have previously been opened. An mdoc(7) block closing macro, a man(7) RE or UE macro, or the end of an equation, table, or roff(7) conditional request is encountered but no matching block is open. The offending request or macro is discarded.
inserting missing end of block
(mdoc , tbl) Various mdoc(7) macros as well as tables require explicit closing by dedicated macros. A block that doesn't support bad nesting ends before all of its children are properly closed. The open child nodes are closed implicitly.
scope open on exit
(mdoc , man , eqn , tbl , roff) At the end of the document, an explicit mdoc(7) block, a man(7) next-line scope or RS or UR block, an equation, table, or roff(7) conditional or ignore block is still open. The open block is closed implicitly.
escaped character not allowed in a name
(roff) Macro, string and register identifiers consist of printable, non-whitespace ASCII characters. Escape sequences and characters and strings expressed in terms of them cannot form part of a name. The first argument of an am , as , de , ds , nr , or rr request, or any argument of an rm request, or the name of a request or user defined macro being called, is terminated by an escape sequence. In the cases of as , ds , and nr , the request has no effect at all. In the cases of am , de , rr , and rm , what was parsed up to this point is used as the arguments to the request, and the rest of the input line is discarded including the escape sequence. When parsing for a request or a user-defined macro name to be called, only the escape sequence is discarded. The characters preceding it are used as the request or macro name, the characters following it are used as the arguments to the request or macro.
argument count wrong
(mdoc , man , roff) The indicated request or macro has too few or too many arguments. The syntax tree will contain the wrong number of arguments as given. Formatting behaviour depends on the specific request or macro in question. Note that the same message may also occur as a WARNING, see above.
missing list type, using -item
(mdoc) A

macro fails to specify the list type.

missing manual name, using dqdq
(mdoc) The first call to lacks the required argument.
uname(3) system call failed, using UNKNOWN
(mdoc) The macro is called without arguments, and the uname(3) system call failed. As a workaround, can be compiled with -D OSNAME=dq\dq string \dqdq .
unknown standard specifier
(mdoc) An St macro has an unknown argument and is discarded.
skipping request without numeric argument
(roff) An it request has a non-numeric or negative argument or no argument at all. The invalid request is ignored.
skipping all arguments
(mdoc , man , eqn , roff) An mdoc(7) is currently in beta test. , Ef , ,

or Ud macro, an
macro in a list that don't support item heads, a man(7) LP , P , or PP macro, an eqn(7) EN macro, or a roff(7) `..' block closing request is invoked with at least one argument. All arguments are ignored.
skipping excess arguments
(mdoc , roff) The Bf macro is invoked with more than one argument, or a request of the de family is invoked with more than two arguments. The excess arguments are ignored.

 

FATAL errors

input too large
(mdoc , man) Currently, cannot handle input files larger than its arbitrary size limit of 2^31 bytes (2 Gigabytes). Since useful manuals are always small, this is not a problem in practice. Parsing is aborted as soon as the condition is detected.
NOT IMPLEMENTED:
(mdoc) For security reasons, the macro does not support the -file argument. By requesting the inclusion of a sensitive file, a malicious document might otherwise trick a privileged user into inadvertently displaying the file on the screen, revealing the file content to bystanders. The parser exits immediately.
NOT IMPLEMENTED: .so with absolute path or dq..dq
(roff) For security reasons, allows so file inclusion requests only with relative paths and only without ascending to any parent directory. By requesting the inclusion of a sensitive file, a malicious document might otherwise trick a privileged user into inadvertently displaying the file on the screen, revealing the file content to bystanders. The parser exits immediately.
.so request failed
(roff) Servicing a so request requires reading an external file. While trying to do so, an open(2), stat(2), or read(2) system call failed. The parser exits immediately. Before showing this message, always shows another message explaining why the system call failed.

 

COMPATIBILITY

This section summarises compatibility with GNU troff. Each input and output format is separately noted.  

ASCII Compatibility