Begins a conditional. Right now, the conditional evaluates to true if and only if it starts with the letter
n, indicating processing in
nroff(1) style as opposed to
troff(1) style. If a conditional is false, its children are not processed, but are syntactically interpreted to preserve the integrity of the input document. Thus,
.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 macro has the following syntax:
.if COND \{ BODY
BODY... \}
.if COND \{ BODY
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 macro ‘.\}'. If the BODY is not enclosed in braces, scope continues until the next macro or word. If the COND is followed by a BODY on the same line, whether after a brace or not, then macros
must begin with a control character. It is generally more intuitive, in this case, to write
.if COND \{\
.foo
bar
.\}
than having the 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 text subsequent a ‘.\}' macro is discarded. Furthermore, if an explicit closing sequence ‘\}' is specified in a free-form line, the entire line is accepted within the scope of the prior macro, not only the text preceding the close, with the ‘\}' collapsing into a zero-width space.