1 .\" $Id: roff.7,v 1.16 2010/12/10 20:58:56 schwarze Exp $
3 .\" Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
4 .\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
6 .\" Permission to use, copy, modify, and distribute this software for any
7 .\" purpose with or without fee is hereby granted, provided that the above
8 .\" copyright notice and this permission notice appear in all copies.
10 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 .Dd $Mdocdate: December 10 2010 $
23 .Nd roff language reference
27 language is a general-purpose text-formatting language. The purpose of
28 this document is to consistently describe those language constructs
31 utility. It is a work in progress.
35 document follows simple rules: lines beginning with the control
40 are parsed for requests and macros.
41 Other lines are interpreted within the scope of
43 .Bd -literal -offset indent
44 \&.xx Macro lines change control state.
45 Other lines are interpreted within the current state.
49 documents may contain only graphable 7-bit ASCII characters, the space
50 character, and, in certain circumstances, the tab character. All
55 Requests and macros are arbitrary in length and begin with a control
60 at the beginning of the line.
61 An arbitrary amount of whitespace may sit between the control character
62 and the request or macro name.
63 Thus, the following are equivalent:
64 .Bd -literal -offset indent
69 This section is a canonical reference of all requests recognized by the
75 language defines many more requests and macros not implemented in
78 Set line adjustment mode.
79 This line-scoped request is intended to have one argument to select
80 normal, left, right, or center adjustment for subsequent text.
81 Currently, it is ignored including its arguments,
82 and the number of arguments is not checked.
84 Append to a macro definition.
85 The syntax of this request is the same as that of
87 It is currently ignored by
91 Append to a macro definition, specifying the macro name indirectly.
92 The syntax of this request is the same as that of
94 It is currently ignored by
98 Append to a macro definition, switching roff compatibility mode off
99 during macro execution.
100 The syntax of this request is the same as that of
102 It is currently ignored by
106 Define a user-defined
109 Its syntax can be either
110 .Bd -literal -offset indent
111 .Pf . Cm \&de Ar name
117 .Bd -literal -offset indent
118 .Pf . Cm \&de Ar name Ar end
123 Both forms define or redefine the macro
126 .Ar macro definition ,
127 which may consist of one or more input lines, including the newline
128 characters terminating each line, optionally containing calls to
132 macros or high-level macros like
136 macros, whichever applies to the document in question.
140 macro works in the same way as for
145 .Ar macro definition ,
146 and after that, it is also evaluated as a
150 macro, but not as a high-level macro.
152 A user-defined macro can be invoked later using the syntax
154 .D1 Pf . Ar name Op Ar argument Op Ar argument ...
156 Arguments are separated by blank characters and can be quoted
159 to allow inclusion of blank characters into arguments.
160 To include the double-quote character into a quoted argument,
161 escape it from ending the argument by doubling it.
163 The line invoking the user-defined macro will be replaced
164 in the input stream by the
165 .Ar macro definition ,
166 replacing all occurrences of
171 .Ar N Ns th Ar argument .
173 .Bd -literal -offset indent
175 \efI\e^\e\e$1\e^\efP\e\e$2
182 .D1 \efI\e^XtFree\e^\efP.
184 in the input stream, and thus in the output: \fI\^XtFree\^\fP.
186 Since user-defined macros and strings share a common string table,
189 clobbers the user-defined string
193 can also be printed using the
195 string interpolation syntax described below
197 but this is rarely useful because every macro definition contains at least
198 one explicit newline character.
200 In order to prevent endless recursion, both groff and
202 limit the stack depth for expanding macros and strings
203 to a large, but finite number.
204 Do not rely on the exact value of this limit.
206 Define a user-defined
208 macro, specifying the macro name indirectly.
209 The syntax of this macro is the same as that of
211 It is currently ignored by
215 Define a user-defined
217 macro that will be executed with
219 compatibility mode switched off during macro execution.
220 This is a GNU extension not available in traditional
222 implementations and not even in older versions of groff.
227 compatibility mode at all, it handles this macro as an alias for
230 Define a user-defined string.
231 Its syntax is as follows:
233 .D1 Pf . Cm \&ds Ar name Oo \(dq Oc Ns Ar string
239 arguments are space-separated.
242 begins with a double-quote character, that character will not be part
244 All remaining characters on the input line form the
246 including whitespace and double-quote characters, even trailing ones.
250 can be interpolated into subsequent text by using
251 .No \e* Ns Bq Ar name
254 of arbitrary length, or \e*(NN or \e*N if the length of
256 is two or one characters, respectively.
258 Since user-defined strings and macros share a common string table,
261 clobbers the user-defined macro
265 used for defining a string can also be invoked as a macro,
266 in which case the following input line will be appended to the
268 forming a new input line passed to the
272 .Bd -literal -offset indent
283 Such abuse is of course strongly discouraged.
287 half of an if/else conditional.
288 Pops a result off the stack of conditional evaluations pushed by
290 and uses it as its conditional.
291 If no stack entries are present (e.g., due to no prior
294 then false is assumed.
295 The syntax of this macro is similar to
297 except that the conditional is missing.
299 Set automatic hyphenation mode.
300 This line-scoped request is currently ignored.
304 half of an if/else conditional.
305 The result of the conditional is pushed into a stack used by subsequent
308 which may be separated by any intervening input (or not exist at all).
309 Its syntax is equivalent to
312 Begins a conditional.
313 Right now, the conditional evaluates to true
314 if and only if it starts with the letter
316 indicating processing in
321 If a conditional is false, its children are not processed, but are
322 syntactically interpreted to preserve the integrity of the input
330 which may lead to interesting results, but
332 .D1 \&.if t \e .if t \e{\e
334 will continue to syntactically interpret to the block close of the final
336 Sub-conditionals, in this case, obviously inherit the truth value of
338 This macro has the following syntax:
340 .Bd -literal -offset indent -compact
345 .Bd -literal -offset indent -compact
349 .Bd -literal -offset indent -compact
354 .Bd -literal -offset indent -compact
359 COND is a conditional statement.
360 roff allows for complicated conditionals; mandoc is much simpler.
361 At this time, mandoc supports only
370 All other invocations are read up to the next end of line or space and
373 If the BODY section is begun by an escaped brace
375 scope continues until a closing-brace macro
377 If the BODY is not enclosed in braces, scope continues until the next
379 If the COND is followed by a BODY on the same line, whether after a
380 brace or not, then macros
382 begin with a control character.
383 It is generally more intuitive, in this case, to write
384 .Bd -literal -offset indent
391 than having the macro follow as
393 .D1 \&.if COND \e{ .foo
395 The scope of a conditional is always parsed, but only executed if the
396 conditional evaluates to true.
398 Note that text subsequent a
401 Furthermore, if an explicit closing sequence
403 is specified in a free-form line, the entire line is accepted within the
404 scope of the prior macro, not only the text preceding the close, with the
406 collapsing into a zero-width space.
409 Its syntax can be either
410 .Bd -literal -offset indent
417 .Bd -literal -offset indent
423 In the first case, input is ignored until a
425 macro is encountered on its own line.
426 In the second case, input is ignored until the specified
428 macro is encountered.
429 Do not use the escape character
431 anywhere in the definition of
433 it would cause very strange behaviour.
437 macro is a roff request or a roff macro, like in
441 the subsequent invocation of
443 will first terminate the
445 then be invoked as usual.
446 Otherwise, it only terminates the
448 and arguments following it or the
452 Declare the need for the specified minimum vertical space
453 before the next trap or the bottom of the page.
454 This line-scoped request is currently ignored.
456 Turn off automatic hyphenation mode.
457 This line-scoped request is currently ignored.
459 Remove a request, macro or string.
460 This request is intended to have one argument,
461 the name of the request, macro or string to be undefined.
462 Currently, it is ignored including its arguments,
463 and the number of arguments is not checked.
466 A register is an arbitrary string value that defines some sort of state,
467 which influences parsing and/or formatting.
468 Its syntax is as follows:
470 .D1 Pf \. Cm \&nr Ar name Ar value
474 may, at the moment, only be an integer.
477 is defined up to the next whitespace.
478 So far, only the following register
483 If set to a positive integer value, certain
485 macros will behave as if they were defined in the
488 Otherwise, this behaviour is unset (even if called within the
491 Note that invoking a new
493 section will unset this value.
496 Include a source file.
497 Its syntax is as follows:
499 .D1 Pf \. Cm \&so Ar file
503 will be read and its contents processed as input in place of the
506 To avoid inadvertant inclusion of unrelated files,
508 only accepts relative paths not containing the strings
513 Output character translation.
514 This macro is intended to have one argument,
515 consisting of an even number of characters.
516 Currently, it is ignored including its arguments,
517 and the number of arguments is not checked.
519 This section documents compatibility between mandoc and other other
520 troff implementations, at this time limited to GNU troff
524 refers to groff versions before the
527 .Pq somewhere between 1.15 and 1.19 .
535 is only compatible with OpenBSD's groff.
537 Historic groff did not accept white-space buffering the custom END tag
544 and family would print funny white-spaces with historic groff when
545 depending on next-line syntax.
551 reference was written by
552 .An Kristaps Dzonsons Aq kristaps@bsd.lv
554 .An Ingo Schwarze Aq schwarze@openbsd.org .