ROFF(7) | Miscellaneous Information Manual | ROFF(7) |
Input lines beginning with the control character ‘.' are parsed for requests and macros. Such lines are called “request lines” or “macro lines”, respectively. Requests change the processing state and manipulate the formatting; some macros also define the document structure and produce formatted output. The single quote (“'”) is accepted as an alternative control character, treated by mandoc(1) just like ‘.
'
Lines not beginning with control characters are called “text lines”. They provide free-form text to be printed; the formatting of the text depends on the respective processing context.
Examples:
.\" This is a comment line. .\" The next line is ignored: . .Sh EXAMPLES \" This is a comment, too. example text \" And so is this.
Examples:
\(em
\e
See mandoc_char(7) for a complete list.
Examples:
\fBbold\fR
\fIitalic\fP
Text decoration is not recommended for mdoc(7), which encourages semantic annotation.
Examples:
\*(Am
\*q
Predefined strings are not recommended for use, as they differ across implementations. Those supported by mandoc(1) are listed in mandoc_char(7). Manuals using these predefined strings are almost certainly not portable.
Unescaped trailing spaces are stripped from text line input unless in a literal context. In general, trailing whitespace on any input line is discouraged for reasons of portability. In the rare case that a blank character is needed at the end of an input line, it may be forced by ‘\ \&'.
Literal space characters can be produced in the output using escape sequences. In macro lines, they can also be included in arguments using quotation; see MACRO SYNTAX for details.
Blank text lines, which may include whitespace, are only permitted within literal contexts. If the first character of a text line is a space, that line is printed with a leading newline.
[+-]?[0-9]*.[0-9]*[:unit:]
', where a decimal must be preceded or followed by at least one digit. Negative numbers, while accepted, are truncated to zero.The following scaling units are accepted:
Using anything other than ‘m', ‘n', ‘u', or ‘v' is necessarily non-portable across output media. See COMPATIBILITY.
If a scaling unit is not provided, the numerical value is interpreted under the default rules of ‘v' for vertical spaces and ‘u' for horizontal ones.
Examples:
The proper spacing is also intelligently preserved if a sentence ends at the boundary of a macro line.
Examples:
Do not end sentences mid-line like this. Instead, end a sentence like this. A macro would end like this: .Xr mandoc 1 .
Thus, the following request lines are all equivalent:
.ig end .ig end . ig end
To be recognised as the beginning of a quoted argument, the opening quote character must be preceded by a space character. A quoted argument extends to the next double quote character that is not part of a pair, or to the end of the input line, whichever comes earlier. Leaving out the terminating double quote character at the end of the line is discouraged. For clarity, if more arguments follow on the same input line, it is recommended to follow the terminating double quote character by a space character; in case the next character after the terminating double quote character is anything else, it is regarded as the beginning of the next, unquoted argument.
Both in quoted and unquoted arguments, pairs of backslashes (‘\\') resolve to single backslashes. In unquoted arguments, space characters can alternatively be included by preceding them with a backslash (‘\ '), but quoting is usually better for clarity.
Examples:
.Fn strlen "const char *s"
.Op "Fl a"
.de name macro definition ..
or
.de name end macro definition .end
Both forms define or redefine the macro name to represent the macro definition, which may consist of one or more input lines, including the newline characters terminating each line, optionally containing calls to roff requests, roff macros or high-level macros like man(7) or mdoc(7) macros, whichever applies to the document in question.
Specifying a custom end macro works in the same way as for ig; namely, the call to ‘.end' first ends the macro definition, and after that, it is also evaluated as a roff request or roff macro, but not as a high-level macro.
The macro can be invoked later using the syntax
.name [argument [argument ...]]
Regarding argument parsing, see MACRO SYNTAX above.
The line invoking the macro will be replaced in the input stream by the macro definition, replacing all occurrences of \\$N, where N is a digit, by the Nth argument. For example,
.de ZN \fI\^\\$1\^\fP\\$2 .. .ZN XtFree .
produces
\fI\^XtFree\^\fP.
in the input stream, and thus in the output: XtFree.
Since macros and user-defined strings share a common string table, defining a macro name clobbers the user-defined string name, and the macro definition can also be printed using the ‘\*' string interpolation syntax described below ds, but this is rarely useful because every macro definition contains at least one explicit newline character.
In order to prevent endless recursion, both groff and mandoc(1) limit the stack depth for expanding macros and strings to a large, but finite number. Do not rely on the exact value of this limit.
.ds name ["]string
The name and string arguments are space-separated. If the string begins with a double-quote character, that character will not be part of the string. All remaining characters on the input line form the string, including whitespace and double-quote characters, even trailing ones.
The string can be interpolated into subsequent text by using \*[name] for a name of arbitrary length, or \*(NN or \*N if the length of name is two or one characters, respectively. Interpolation can be prevented by escaping the leading backslash; that is, an asterisk preceded by an even number of backslashes does not trigger string interpolation.
Since user-defined strings and macros share a common string table, defining a string name clobbers the macro name, and the name used for defining a string can also be invoked as a macro, in which case the following input line will be appended to the string, forming a new input line passed to the roff parser. For example,
.ds badidea .S .badidea H SYNOPSIS
invokes the SH macro when used in a man(7) document. Such abuse is of course strongly discouraged.
.if t .ig
will discard the ‘.ig', which may lead to interesting results, but
.if t .if t \{\
will continue to syntactically interpret to the block close of the final conditional. Sub-conditionals, in this case, obviously inherit the truth value of the parent. This request has the following syntax:
.if COND \{\ BODY... .\}
.if COND \{ BODY BODY... \}
.if COND \{ BODY BODY... .\}
.if COND \ BODY
COND is a conditional statement. roff allows for complicated conditionals; mandoc is much simpler. At this time, mandoc supports only ‘n', evaluating to true; and ‘t', ‘e', and ‘o', evaluating to false. All other invocations are read up to the next end of line or space and evaluate as false.
If the BODY section is begun by an escaped brace ‘\{', scope continues until a closing-brace escape sequence ‘.\}'. If the BODY is not enclosed in braces, scope continues until the end of the line. If the COND is followed by a BODY on the same line, whether after a brace or not, then requests and macros must begin with a control character. It is generally more intuitive, in this case, to write
.if COND \{\ .foo bar .\}
than having the request or macro follow as
.if COND \{ .foo
The scope of a conditional is always parsed, but only executed if the conditional evaluates to true.
Note that the ‘\}' is converted into a zero-width escape sequence if not passed as a standalone macro ‘.\}'. For example,
.Fl a \} b
will result in ‘\}' being considered an argument of the ‘Fl' macro.
.ig ignored text ..
or
.ig end ignored text .end
In the first case, input is ignored until a ‘..' request is encountered on its own line. In the second case, input is ignored until the specified ‘.end' macro is encountered. Do not use the escape character ‘\' anywhere in the definition of end; it would cause very strange behaviour.
When the end macro is a roff request or a roff macro, like in
.ig if
the subsequent invocation of if will first terminate the ignored text, then be invoked as usual. Otherwise, it only terminates the ignored text, and arguments following it or the ‘..' request are discarded.
.nr name value
The value may, at the moment, only be an integer. So far, only the following register name is recognised:
.so file
The file will be read and its contents processed as input in place of the ‘.so' request line. To avoid inadvertent inclusion of unrelated files, mandoc(1) only accepts relative paths not containing the strings “../” and “/..”.
This request requires man(1) to change to the right directory before calling mandoc(1), per convention to the root of the manual tree. Typical usage looks like:
.so man3/Xcursor.3
As the whole concept is rather fragile, the use of so is discouraged. Use ln(1) instead.
.tr [ab]+
Pairs of ab characters are replaced (a for b). Replacement (or origin) characters may also be character escapes; thus,
tr \(xx\(yy
replaces all invocations of \(xx with \(yy.
Joseph F. Ossanna and Brian W. Kernighan, Troff User's Manual, AT&T Bell Laboratories, Computing Science Technical Report, 54, 1976 and 1992, Murray Hill, New Jersey, http://www.kohala.com/start/troff/cstr54.ps.
Joseph F. Ossanna, Brian W. Kernighan, and Gunnar Ritter, Heirloom Documentation Tools Nroff/Troff User's Manual, September 17, 2007, http://heirloom.sourceforge.net/doctools/troff.pdf.
December 11, 2011 | NetBSD 6.1 |