Annotation of mandoc/roff.7, Revision 1.42
1.42 ! schwarze 1: .\" $Id: roff.7,v 1.41 2013/07/13 19:41:16 schwarze Exp $
1.1 kristaps 2: .\"
1.33 schwarze 3: .\" Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4: .\" Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
1.1 kristaps 5: .\"
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.
9: .\"
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.
17: .\"
1.42 ! schwarze 18: .Dd $Mdocdate: July 13 2013 $
1.1 kristaps 19: .Dt ROFF 7
20: .Os
21: .Sh NAME
22: .Nm roff
1.17 schwarze 23: .Nd roff language reference for mandoc
1.1 kristaps 24: .Sh DESCRIPTION
25: The
26: .Nm roff
1.17 schwarze 27: language is a general purpose text formatting language.
1.33 schwarze 28: Since traditional implementations of the
1.17 schwarze 29: .Xr mdoc 7
30: and
31: .Xr man 7
1.33 schwarze 32: manual formatting languages are based on it,
33: many real-world manuals use small numbers of
1.17 schwarze 34: .Nm
1.33 schwarze 35: requests intermixed with their
36: .Xr mdoc 7
37: or
38: .Xr man 7
39: code.
40: To properly format such manuals, the
1.1 kristaps 41: .Xr mandoc 1
1.33 schwarze 42: utility supports a tiny subset of
43: .Nm
44: requests.
45: Only these requests supported by
46: .Xr mandoc 1
47: are documented in the present manual,
48: together with the basic language syntax shared by
49: .Nm ,
50: .Xr mdoc 7 ,
51: and
52: .Xr man 7 .
53: For complete
54: .Nm
55: manuals, consult the
56: .Sx SEE ALSO
57: section.
1.1 kristaps 58: .Pp
1.33 schwarze 59: Input lines beginning with the control character
1.17 schwarze 60: .Sq \&.
1.33 schwarze 61: are parsed for requests and macros.
62: Such lines are called
63: .Dq request lines
1.1 kristaps 64: or
1.33 schwarze 65: .Dq macro lines ,
66: respectively.
67: Requests change the processing state and manipulate the formatting;
68: some macros also define the document structure and produce formatted
69: output.
70: The single quote
71: .Pq Qq \(aq
72: is accepted as an alternative control character,
73: treated by
74: .Xr mandoc 1
75: just like
76: .Ql \&.
77: .Pp
78: Lines not beginning with control characters are called
79: .Dq text lines .
80: They provide free-form text to be printed; the formatting of the text
81: depends on the respective processing context.
1.1 kristaps 82: .Sh LANGUAGE SYNTAX
83: .Nm
84: documents may contain only graphable 7-bit ASCII characters, the space
1.17 schwarze 85: character, and, in certain circumstances, the tab character.
1.38 kristaps 86: The backslash character
1.33 schwarze 87: .Sq \e
88: indicates the start of an escape sequence for
89: .Sx Comments ,
90: .Sx Special Characters ,
91: .Sx Predefined Strings ,
92: and
93: user-defined strings defined using the
94: .Sx ds
95: request.
96: .Ss Comments
97: Text following an escaped double-quote
98: .Sq \e\(dq ,
99: whether in a request, macro, or text line, is ignored to the end of the line.
100: A request line beginning with a control character and comment escape
101: .Sq \&.\e\(dq
102: is also ignored.
103: Furthermore, request lines with only a control character and optional
104: trailing whitespace are stripped from input.
105: .Pp
106: Examples:
107: .Bd -literal -offset indent -compact
108: \&.\e\(dq This is a comment line.
109: \&.\e\(dq The next line is ignored:
110: \&.
111: \&.Sh EXAMPLES \e\(dq This is a comment, too.
112: \&example text \e\(dq And so is this.
113: .Ed
114: .Ss Special Characters
115: Special characters are used to encode special glyphs and are rendered
116: differently across output media.
117: They may occur in request, macro, and text lines.
118: Sequences begin with the escape character
119: .Sq \e
120: followed by either an open-parenthesis
121: .Sq \&(
122: for two-character sequences; an open-bracket
123: .Sq \&[
124: for n-character sequences (terminated at a close-bracket
125: .Sq \&] ) ;
126: or a single one character sequence.
127: .Pp
128: Examples:
129: .Bl -tag -width Ds -offset indent -compact
130: .It Li \e(em
131: Two-letter em dash escape.
132: .It Li \ee
133: One-letter backslash escape.
134: .El
135: .Pp
136: See
1.17 schwarze 137: .Xr mandoc_char 7
1.33 schwarze 138: for a complete list.
139: .Ss Text Decoration
140: Terms may be text-decorated using the
141: .Sq \ef
142: escape followed by an indicator: B (bold), I (italic), R (regular), or P
143: (revert to previous mode).
144: A numerical representation 3, 2, or 1 (bold, italic, and regular,
145: respectively) may be used instead.
1.34 kristaps 146: The indicator or numerical representative may be preceded by C
147: (constant-width), which is ignored.
1.33 schwarze 148: .Pp
1.42 ! schwarze 149: The two-character indicator
! 150: .Sq BI
! 151: requests a font that is both bold and italic.
! 152: It may not be portable to old roff implementations.
! 153: .Pp
1.33 schwarze 154: Examples:
155: .Bl -tag -width Ds -offset indent -compact
156: .It Li \efBbold\efR
1.42 ! schwarze 157: Write in \fBbold\fP, then switch to regular font mode.
1.33 schwarze 158: .It Li \efIitalic\efP
1.42 ! schwarze 159: Write in \fIitalic\fP, then return to previous font mode.
! 160: .It Li \ef(BIbold italic\efP
! 161: Write in \f(BIbold italic\fP, then return to previous font mode.
1.33 schwarze 162: .El
163: .Pp
164: Text decoration is
165: .Em not
166: recommended for
167: .Xr mdoc 7 ,
168: which encourages semantic annotation.
169: .Ss Predefined Strings
170: Predefined strings, like
171: .Sx Special Characters ,
172: mark special output glyphs.
173: Predefined strings are escaped with the slash-asterisk,
174: .Sq \e* :
175: single-character
176: .Sq \e*X ,
177: two-character
178: .Sq \e*(XX ,
179: and N-character
180: .Sq \e*[N] .
181: .Pp
182: Examples:
183: .Bl -tag -width Ds -offset indent -compact
184: .It Li \e*(Am
185: Two-letter ampersand predefined string.
186: .It Li \e*q
187: One-letter double-quote predefined string.
188: .El
189: .Pp
190: Predefined strings are not recommended for use,
191: as they differ across implementations.
192: Those supported by
193: .Xr mandoc 1
194: are listed in
195: .Xr mandoc_char 7 .
196: Manuals using these predefined strings are almost certainly not portable.
197: .Ss Whitespace
198: Whitespace consists of the space character.
199: In text lines, whitespace is preserved within a line.
200: In request and macro lines, whitespace delimits arguments and is discarded.
201: .Pp
202: Unescaped trailing spaces are stripped from text line input unless in a
203: literal context.
204: In general, trailing whitespace on any input line is discouraged for
205: reasons of portability.
206: In the rare case that a blank character is needed at the end of an
207: input line, it may be forced by
208: .Sq \e\ \e& .
209: .Pp
210: Literal space characters can be produced in the output
211: using escape sequences.
212: In macro lines, they can also be included in arguments using quotation; see
213: .Sx MACRO SYNTAX
214: for details.
215: .Pp
216: Blank text lines, which may include whitespace, are only permitted
217: within literal contexts.
218: If the first character of a text line is a space, that line is printed
219: with a leading newline.
220: .Ss Scaling Widths
221: Many requests and macros support scaled widths for their arguments.
222: The syntax for a scaled width is
223: .Sq Li [+-]?[0-9]*.[0-9]*[:unit:] ,
224: where a decimal must be preceded or followed by at least one digit.
225: Negative numbers, while accepted, are truncated to zero.
226: .Pp
227: The following scaling units are accepted:
228: .Pp
229: .Bl -tag -width Ds -offset indent -compact
230: .It c
231: centimetre
232: .It i
233: inch
234: .It P
235: pica (~1/6 inch)
236: .It p
237: point (~1/72 inch)
238: .It f
239: synonym for
240: .Sq u
241: .It v
242: default vertical span
243: .It m
244: width of rendered
245: .Sq m
246: .Pq em
247: character
248: .It n
249: width of rendered
250: .Sq n
251: .Pq en
252: character
253: .It u
254: default horizontal span
255: .It M
256: mini-em (~1/100 em)
257: .El
258: .Pp
259: Using anything other than
260: .Sq m ,
261: .Sq n ,
262: .Sq u ,
263: or
264: .Sq v
265: is necessarily non-portable across output media.
266: See
267: .Sx COMPATIBILITY .
268: .Pp
269: If a scaling unit is not provided, the numerical value is interpreted
270: under the default rules of
271: .Sq v
272: for vertical spaces and
273: .Sq u
274: for horizontal ones.
275: .Pp
276: Examples:
277: .Bl -tag -width ".Bl -tag -width 2i" -offset indent -compact
278: .It Li \&.Bl -tag -width 2i
279: two-inch tagged list indentation in
280: .Xr mdoc 7
281: .It Li \&.HP 2i
282: two-inch tagged list indentation in
283: .Xr man 7
284: .It Li \&.sp 2v
285: two vertical spaces
286: .El
287: .Ss Sentence Spacing
288: Each sentence should terminate at the end of an input line.
289: By doing this, a formatter will be able to apply the proper amount of
290: spacing after the end of sentence (unescaped) period, exclamation mark,
291: or question mark followed by zero or more non-sentence closing
292: delimiters
293: .Po
294: .Sq \&) ,
295: .Sq \&] ,
296: .Sq \&' ,
297: .Sq \&"
298: .Pc .
299: .Pp
300: The proper spacing is also intelligently preserved if a sentence ends at
301: the boundary of a macro line.
302: .Pp
303: Examples:
304: .Bd -literal -offset indent -compact
305: Do not end sentences mid-line like this. Instead,
306: end a sentence like this.
307: A macro would end like this:
308: \&.Xr mandoc 1 \&.
309: .Ed
1.17 schwarze 310: .Sh REQUEST SYNTAX
311: A request or macro line consists of:
312: .Pp
313: .Bl -enum -compact
314: .It
315: the control character
316: .Sq \&.
1.1 kristaps 317: or
1.17 schwarze 318: .Sq \(aq
319: at the beginning of the line,
320: .It
321: optionally an arbitrary amount of whitespace,
322: .It
323: the name of the request or the macro, which is one word of arbitrary
324: length, terminated by whitespace,
325: .It
326: and zero or more arguments delimited by whitespace.
327: .El
328: .Pp
329: Thus, the following request lines are all equivalent:
1.1 kristaps 330: .Bd -literal -offset indent
1.17 schwarze 331: \&.ig end
332: \&.ig end
333: \&. ig end
1.1 kristaps 334: .Ed
1.24 schwarze 335: .Sh MACRO SYNTAX
1.33 schwarze 336: Macros are provided by the
337: .Xr mdoc 7
338: and
339: .Xr man 7
340: languages and can be defined by the
1.24 schwarze 341: .Sx \&de
342: request.
343: When called, they follow the same syntax as requests, except that
344: macro arguments may optionally be quoted by enclosing them
345: in double quote characters
346: .Pq Sq \(dq .
1.33 schwarze 347: Quoted text, even if it contains whitespace or would cause
348: a macro invocation when unquoted, is always considered literal text.
349: Inside quoted text, pairs of double quote characters
350: .Pq Sq Qq
351: resolve to single double quote characters.
352: .Pp
1.32 kristaps 353: To be recognised as the beginning of a quoted argument, the opening
1.24 schwarze 354: quote character must be preceded by a space character.
355: A quoted argument extends to the next double quote character that is not
356: part of a pair, or to the end of the input line, whichever comes earlier.
357: Leaving out the terminating double quote character at the end of the line
358: is discouraged.
359: For clarity, if more arguments follow on the same input line,
360: it is recommended to follow the terminating double quote character
361: by a space character; in case the next character after the terminating
362: double quote character is anything else, it is regarded as the beginning
363: of the next, unquoted argument.
364: .Pp
365: Both in quoted and unquoted arguments, pairs of backslashes
366: .Pq Sq \e\e
367: resolve to single backslashes.
368: In unquoted arguments, space characters can alternatively be included
369: by preceding them with a backslash
370: .Pq Sq \e\~ ,
371: but quoting is usually better for clarity.
1.33 schwarze 372: .Pp
373: Examples:
374: .Bl -tag -width Ds -offset indent -compact
375: .It Li .Fn strlen \(dqconst char *s\(dq
376: Group arguments
377: .Qq const char *s
378: into one function argument.
379: If unspecified,
380: .Qq const ,
381: .Qq char ,
382: and
383: .Qq *s
384: would be considered separate arguments.
385: .It Li .Op \(dqFl a\(dq
386: Consider
387: .Qq \&Fl a
388: as literal text instead of a flag macro.
389: .El
1.15 kristaps 390: .Sh REQUEST REFERENCE
1.17 schwarze 391: The
1.15 kristaps 392: .Xr mandoc 1
393: .Nm
1.32 kristaps 394: parser recognises the following requests.
1.17 schwarze 395: Note that the
1.15 kristaps 396: .Nm
1.17 schwarze 397: language defines many more requests not implemented in
1.15 kristaps 398: .Xr mandoc 1 .
399: .Ss \&ad
400: Set line adjustment mode.
401: This line-scoped request is intended to have one argument to select
1.32 kristaps 402: normal, left, right, or centre adjustment for subsequent text.
1.15 kristaps 403: Currently, it is ignored including its arguments,
404: and the number of arguments is not checked.
1.3 kristaps 405: .Ss \&am
1.15 kristaps 406: Append to a macro definition.
407: The syntax of this request is the same as that of
408: .Sx \&de .
409: It is currently ignored by
410: .Xr mandoc 1 ,
411: as are its children.
1.3 kristaps 412: .Ss \&ami
1.15 kristaps 413: Append to a macro definition, specifying the macro name indirectly.
414: The syntax of this request is the same as that of
415: .Sx \&dei .
416: It is currently ignored by
417: .Xr mandoc 1 ,
418: as are its children.
1.3 kristaps 419: .Ss \&am1
1.15 kristaps 420: Append to a macro definition, switching roff compatibility mode off
421: during macro execution.
422: The syntax of this request is the same as that of
423: .Sx \&de1 .
424: It is currently ignored by
425: .Xr mandoc 1 ,
426: as are its children.
1.39 kristaps 427: .Ss \&cc
428: Changes the control character.
429: Its syntax is as follows:
430: .Bd -literal -offset indent
431: .Pf . Cm \&cc Op Ar c
432: .Ed
433: .Pp
434: If
435: .Ar c
436: is not specified, the control character is reset to
437: .Sq \&. .
438: Trailing characters are ignored.
1.3 kristaps 439: .Ss \&de
1.17 schwarze 440: Define a
1.15 kristaps 441: .Nm
442: macro.
443: Its syntax can be either
444: .Bd -literal -offset indent
445: .Pf . Cm \&de Ar name
446: .Ar macro definition
447: \&..
448: .Ed
449: .Pp
450: or
451: .Bd -literal -offset indent
452: .Pf . Cm \&de Ar name Ar end
453: .Ar macro definition
454: .Pf . Ar end
455: .Ed
456: .Pp
457: Both forms define or redefine the macro
458: .Ar name
459: to represent the
460: .Ar macro definition ,
461: which may consist of one or more input lines, including the newline
462: characters terminating each line, optionally containing calls to
463: .Nm
464: requests,
465: .Nm
466: macros or high-level macros like
467: .Xr man 7
468: or
469: .Xr mdoc 7
470: macros, whichever applies to the document in question.
471: .Pp
472: Specifying a custom
473: .Ar end
474: macro works in the same way as for
475: .Sx \&ig ;
476: namely, the call to
477: .Sq Pf . Ar end
478: first ends the
479: .Ar macro definition ,
480: and after that, it is also evaluated as a
481: .Nm
482: request or
483: .Nm
484: macro, but not as a high-level macro.
485: .Pp
1.17 schwarze 486: The macro can be invoked later using the syntax
1.15 kristaps 487: .Pp
488: .D1 Pf . Ar name Op Ar argument Op Ar argument ...
489: .Pp
1.24 schwarze 490: Regarding argument parsing, see
491: .Sx MACRO SYNTAX
492: above.
1.15 kristaps 493: .Pp
1.17 schwarze 494: The line invoking the macro will be replaced
1.15 kristaps 495: in the input stream by the
496: .Ar macro definition ,
497: replacing all occurrences of
498: .No \e\e$ Ns Ar N ,
1.17 schwarze 499: where
1.15 kristaps 500: .Ar N
501: is a digit, by the
502: .Ar N Ns th Ar argument .
503: For example,
504: .Bd -literal -offset indent
505: \&.de ZN
506: \efI\e^\e\e$1\e^\efP\e\e$2
507: \&..
508: \&.ZN XtFree .
509: .Ed
510: .Pp
511: produces
512: .Pp
513: .D1 \efI\e^XtFree\e^\efP.
514: .Pp
515: in the input stream, and thus in the output: \fI\^XtFree\^\fP.
516: .Pp
1.17 schwarze 517: Since macros and user-defined strings share a common string table,
1.15 kristaps 518: defining a macro
519: .Ar name
520: clobbers the user-defined string
521: .Ar name ,
522: and the
523: .Ar macro definition
524: can also be printed using the
525: .Sq \e*
526: string interpolation syntax described below
527: .Sx ds ,
528: but this is rarely useful because every macro definition contains at least
529: one explicit newline character.
1.16 schwarze 530: .Pp
531: In order to prevent endless recursion, both groff and
532: .Xr mandoc 1
533: limit the stack depth for expanding macros and strings
534: to a large, but finite number.
535: Do not rely on the exact value of this limit.
1.3 kristaps 536: .Ss \&dei
1.17 schwarze 537: Define a
1.15 kristaps 538: .Nm
539: macro, specifying the macro name indirectly.
1.17 schwarze 540: The syntax of this request is the same as that of
1.15 kristaps 541: .Sx \&de .
542: It is currently ignored by
543: .Xr mandoc 1 ,
544: as are its children.
545: .Ss \&de1
1.17 schwarze 546: Define a
1.15 kristaps 547: .Nm
548: macro that will be executed with
549: .Nm
550: compatibility mode switched off during macro execution.
551: This is a GNU extension not available in traditional
552: .Nm
553: implementations and not even in older versions of groff.
554: Since
555: .Xr mandoc 1
556: does not implement
557: .Nm
1.17 schwarze 558: compatibility mode at all, it handles this request as an alias for
1.15 kristaps 559: .Sx \&de .
1.6 schwarze 560: .Ss \&ds
1.15 kristaps 561: Define a user-defined string.
1.13 kristaps 562: Its syntax is as follows:
563: .Pp
1.15 kristaps 564: .D1 Pf . Cm \&ds Ar name Oo \(dq Oc Ns Ar string
1.13 kristaps 565: .Pp
566: The
1.15 kristaps 567: .Ar name
1.13 kristaps 568: and
1.15 kristaps 569: .Ar string
570: arguments are space-separated.
571: If the
572: .Ar string
573: begins with a double-quote character, that character will not be part
574: of the string.
575: All remaining characters on the input line form the
576: .Ar string ,
577: including whitespace and double-quote characters, even trailing ones.
578: .Pp
1.13 kristaps 579: The
1.15 kristaps 580: .Ar string
581: can be interpolated into subsequent text by using
582: .No \e* Ns Bq Ar name
583: for a
584: .Ar name
585: of arbitrary length, or \e*(NN or \e*N if the length of
586: .Ar name
587: is two or one characters, respectively.
1.17 schwarze 588: Interpolation can be prevented by escaping the leading backslash;
589: that is, an asterisk preceded by an even number of backslashes
590: does not trigger string interpolation.
1.15 kristaps 591: .Pp
592: Since user-defined strings and macros share a common string table,
593: defining a string
594: .Ar name
1.17 schwarze 595: clobbers the macro
1.15 kristaps 596: .Ar name ,
597: and the
598: .Ar name
599: used for defining a string can also be invoked as a macro,
600: in which case the following input line will be appended to the
601: .Ar string ,
602: forming a new input line passed to the
603: .Nm
604: parser.
605: For example,
606: .Bd -literal -offset indent
607: \&.ds badidea .S
608: \&.badidea
609: H SYNOPSIS
610: .Ed
611: .Pp
612: invokes the
613: .Cm SH
614: macro when used in a
615: .Xr man 7
616: document.
617: Such abuse is of course strongly discouraged.
1.5 kristaps 618: .Ss \&el
619: The
620: .Qq else
621: half of an if/else conditional.
622: Pops a result off the stack of conditional evaluations pushed by
623: .Sx \&ie
624: and uses it as its conditional.
625: If no stack entries are present (e.g., due to no prior
626: .Sx \&ie
627: calls)
628: then false is assumed.
1.17 schwarze 629: The syntax of this request is similar to
1.5 kristaps 630: .Sx \&if
631: except that the conditional is missing.
1.27 kristaps 632: .Ss \&EN
633: End an equation block.
634: See
635: .Sx \&EQ .
636: .Ss \&EQ
637: Begin an equation block.
638: See
639: .Xr eqn 7
640: for a description of the equation language.
1.15 kristaps 641: .Ss \&hy
642: Set automatic hyphenation mode.
643: This line-scoped request is currently ignored.
1.5 kristaps 644: .Ss \&ie
645: The
646: .Qq if
647: half of an if/else conditional.
648: The result of the conditional is pushed into a stack used by subsequent
649: invocations of
650: .Sx \&el ,
651: which may be separated by any intervening input (or not exist at all).
652: Its syntax is equivalent to
653: .Sx \&if .
1.1 kristaps 654: .Ss \&if
1.7 schwarze 655: Begins a conditional.
656: Right now, the conditional evaluates to true
657: if and only if it starts with the letter
658: .Sy n ,
1.17 schwarze 659: indicating processing in nroff style as opposed to troff style.
1.3 kristaps 660: If a conditional is false, its children are not processed, but are
661: syntactically interpreted to preserve the integrity of the input
662: document.
663: Thus,
664: .Pp
1.17 schwarze 665: .D1 \&.if t .ig
1.3 kristaps 666: .Pp
667: will discard the
668: .Sq \&.ig ,
669: which may lead to interesting results, but
670: .Pp
1.17 schwarze 671: .D1 \&.if t .if t \e{\e
1.3 kristaps 672: .Pp
673: will continue to syntactically interpret to the block close of the final
674: conditional.
675: Sub-conditionals, in this case, obviously inherit the truth value of
676: the parent.
1.17 schwarze 677: This request has the following syntax:
678: .Bd -literal -offset indent
1.1 kristaps 679: \&.if COND \e{\e
680: BODY...
681: \&.\e}
682: .Ed
1.17 schwarze 683: .Bd -literal -offset indent
1.1 kristaps 684: \&.if COND \e{ BODY
1.2 kristaps 685: BODY... \e}
686: .Ed
1.17 schwarze 687: .Bd -literal -offset indent
1.2 kristaps 688: \&.if COND \e{ BODY
1.1 kristaps 689: BODY...
690: \&.\e}
691: .Ed
1.17 schwarze 692: .Bd -literal -offset indent
1.1 kristaps 693: \&.if COND \e
694: BODY
695: .Ed
696: .Pp
1.9 kristaps 697: COND is a conditional statement.
698: roff allows for complicated conditionals; mandoc is much simpler.
699: At this time, mandoc supports only
700: .Sq n ,
701: evaluating to true;
702: and
703: .Sq t ,
704: .Sq e ,
705: and
706: .Sq o ,
707: evaluating to false.
708: All other invocations are read up to the next end of line or space and
709: evaluate as false.
1.1 kristaps 710: .Pp
711: If the BODY section is begun by an escaped brace
712: .Sq \e{ ,
1.17 schwarze 713: scope continues until a closing-brace escape sequence
1.1 kristaps 714: .Sq \.\e} .
1.17 schwarze 715: If the BODY is not enclosed in braces, scope continues until
716: the end of the line.
1.1 kristaps 717: If the COND is followed by a BODY on the same line, whether after a
1.17 schwarze 718: brace or not, then requests and macros
1.1 kristaps 719: .Em must
720: begin with a control character.
721: It is generally more intuitive, in this case, to write
722: .Bd -literal -offset indent
723: \&.if COND \e{\e
724: \&.foo
725: bar
726: \&.\e}
727: .Ed
728: .Pp
1.17 schwarze 729: than having the request or macro follow as
1.1 kristaps 730: .Pp
731: .D1 \&.if COND \e{ .foo
732: .Pp
733: The scope of a conditional is always parsed, but only executed if the
734: conditional evaluates to true.
735: .Pp
1.29 kristaps 736: Note that the
1.1 kristaps 737: .Sq \e}
1.29 kristaps 738: is converted into a zero-width escape sequence if not passed as a
739: standalone macro
740: .Sq \&.\e} .
741: For example,
742: .Pp
743: .D1 \&.Fl a \e} b
744: .Pp
745: will result in
1.8 kristaps 746: .Sq \e}
1.29 kristaps 747: being considered an argument of the
748: .Sq \&Fl
749: macro.
1.1 kristaps 750: .Ss \&ig
1.2 kristaps 751: Ignore input.
1.15 kristaps 752: Its syntax can be either
753: .Bd -literal -offset indent
754: .Pf . Cm \&ig
755: .Ar ignored text
1.2 kristaps 756: \&..
757: .Ed
1.15 kristaps 758: .Pp
759: or
760: .Bd -literal -offset indent
761: .Pf . Cm \&ig Ar end
762: .Ar ignored text
763: .Pf . Ar end
1.2 kristaps 764: .Ed
765: .Pp
766: In the first case, input is ignored until a
767: .Sq \&..
1.17 schwarze 768: request is encountered on its own line.
1.15 kristaps 769: In the second case, input is ignored until the specified
770: .Sq Pf . Ar end
771: macro is encountered.
772: Do not use the escape character
1.2 kristaps 773: .Sq \e
1.15 kristaps 774: anywhere in the definition of
775: .Ar end ;
776: it would cause very strange behaviour.
777: .Pp
778: When the
779: .Ar end
780: macro is a roff request or a roff macro, like in
1.2 kristaps 781: .Pp
782: .D1 \&.ig if
783: .Pp
784: the subsequent invocation of
785: .Sx \&if
1.15 kristaps 786: will first terminate the
787: .Ar ignored text ,
788: then be invoked as usual.
789: Otherwise, it only terminates the
790: .Ar ignored text ,
791: and arguments following it or the
792: .Sq \&..
1.17 schwarze 793: request are discarded.
1.15 kristaps 794: .Ss \&ne
795: Declare the need for the specified minimum vertical space
796: before the next trap or the bottom of the page.
797: This line-scoped request is currently ignored.
798: .Ss \&nh
799: Turn off automatic hyphenation mode.
800: This line-scoped request is currently ignored.
1.6 schwarze 801: .Ss \&rm
802: Remove a request, macro or string.
1.15 kristaps 803: This request is intended to have one argument,
1.6 schwarze 804: the name of the request, macro or string to be undefined.
805: Currently, it is ignored including its arguments,
806: and the number of arguments is not checked.
1.10 kristaps 807: .Ss \&nr
808: Define a register.
809: A register is an arbitrary string value that defines some sort of state,
810: which influences parsing and/or formatting.
811: Its syntax is as follows:
812: .Pp
1.15 kristaps 813: .D1 Pf \. Cm \&nr Ar name Ar value
1.10 kristaps 814: .Pp
815: The
1.15 kristaps 816: .Ar value
1.10 kristaps 817: may, at the moment, only be an integer.
1.15 kristaps 818: So far, only the following register
819: .Ar name
820: is recognised:
1.10 kristaps 821: .Bl -tag -width Ds
822: .It Cm nS
823: If set to a positive integer value, certain
824: .Xr mdoc 7
1.17 schwarze 825: macros will behave in the same way as in the
1.10 kristaps 826: .Em SYNOPSIS
1.11 kristaps 827: section.
1.17 schwarze 828: If set to 0, these macros will behave in the same way as outside the
829: .Em SYNOPSIS
830: section, even when called within the
1.10 kristaps 831: .Em SYNOPSIS
1.17 schwarze 832: section itself.
833: Note that starting a new
1.11 kristaps 834: .Xr mdoc 7
1.17 schwarze 835: section with the
836: .Cm \&Sh
837: macro will reset this register.
1.10 kristaps 838: .El
1.26 schwarze 839: .Ss \&ns
840: Turn on no-space mode.
841: This line-scoped request is intended to take no arguments.
842: Currently, it is ignored including its arguments,
843: and the number of arguments is not checked.
844: .Ss \&ps
845: Change point size.
846: This line-scoped request is intended to take one numerical argument.
847: Currently, it is ignored including its arguments,
848: and the number of arguments is not checked.
1.15 kristaps 849: .Ss \&so
850: Include a source file.
851: Its syntax is as follows:
852: .Pp
853: .D1 Pf \. Cm \&so Ar file
854: .Pp
855: The
856: .Ar file
857: will be read and its contents processed as input in place of the
858: .Sq \&.so
859: request line.
1.28 kristaps 860: To avoid inadvertent inclusion of unrelated files,
1.15 kristaps 861: .Xr mandoc 1
862: only accepts relative paths not containing the strings
863: .Qq ../
864: and
865: .Qq /.. .
1.37 schwarze 866: .Pp
867: This request requires
868: .Xr man 1
869: to change to the right directory before calling
870: .Xr mandoc 1 ,
871: per convention to the root of the manual tree.
872: Typical usage looks like:
873: .Pp
874: .Dl \&.so man3/Xcursor.3
875: .Pp
876: As the whole concept is rather fragile, the use of
877: .Sx \&so
878: is discouraged.
879: Use
880: .Xr ln 1
881: instead.
1.26 schwarze 882: .Ss \&ta
883: Set tab stops.
884: This line-scoped request can take an arbitrary number of arguments.
885: Currently, it is ignored including its arguments.
1.6 schwarze 886: .Ss \&tr
887: Output character translation.
1.30 kristaps 888: Its syntax is as follows:
889: .Pp
890: .D1 Pf \. Cm \&tr Ar [ab]+
891: .Pp
892: Pairs of
893: .Ar ab
894: characters are replaced
895: .Ar ( a
896: for
897: .Ar b ) .
898: Replacement (or origin) characters may also be character escapes; thus,
899: .Pp
900: .Dl tr \e(xx\e(yy
901: .Pp
902: replaces all invocations of \e(xx with \e(yy.
1.20 kristaps 903: .Ss \&T&
904: Re-start a table layout, retaining the options of the prior table
905: invocation.
906: See
907: .Sx \&TS .
908: .Ss \&TE
909: End a table context.
910: See
911: .Sx \&TS .
912: .Ss \&TS
913: Begin a table, which formats input in aligned rows and columns.
1.23 kristaps 914: See
915: .Xr tbl 7
916: for a description of the tbl language.
1.2 kristaps 917: .Sh COMPATIBILITY
1.40 schwarze 918: This section documents compatibility between mandoc and other
1.17 schwarze 919: .Nm
920: implementations, at this time limited to GNU troff
1.2 kristaps 921: .Pq Qq groff .
922: The term
923: .Qq historic groff
1.17 schwarze 924: refers to groff version 1.15.
1.2 kristaps 925: .Pp
926: .Bl -dash -compact
1.10 kristaps 927: .It
1.27 kristaps 928: In mandoc, the
929: .Sx \&EQ ,
930: .Sx \&TE ,
931: .Sx \&TS ,
932: and
933: .Sx \&T& ,
934: macros are considered regular macros.
935: In all other
936: .Nm
937: implementations, these are special macros that must be specified without
938: spacing between the control character (which must be a period) and the
939: macro name.
940: .It
1.10 kristaps 941: The
942: .Cm nS
1.17 schwarze 943: register is only compatible with OpenBSD's groff-1.15.
1.2 kristaps 944: .It
1.17 schwarze 945: Historic groff did not accept white-space before a custom
946: .Ar end
947: macro for the
1.2 kristaps 948: .Sx \&ig
1.17 schwarze 949: request.
1.4 kristaps 950: .It
951: The
952: .Sx \&if
953: and family would print funny white-spaces with historic groff when
1.17 schwarze 954: using the next-line syntax.
1.2 kristaps 955: .El
1.17 schwarze 956: .Sh SEE ALSO
957: .Xr mandoc 1 ,
1.27 kristaps 958: .Xr eqn 7 ,
1.17 schwarze 959: .Xr man 7 ,
960: .Xr mandoc_char 7 ,
1.23 kristaps 961: .Xr mdoc 7 ,
962: .Xr tbl 7
1.17 schwarze 963: .Rs
964: .%A Joseph F. Ossanna
965: .%A Brian W. Kernighan
966: .%I AT&T Bell Laboratories
967: .%T Troff User's Manual
968: .%R Computing Science Technical Report
969: .%N 54
970: .%C Murray Hill, New Jersey
971: .%D 1976 and 1992
972: .%U http://www.kohala.com/start/troff/cstr54.ps
973: .Re
974: .Rs
975: .%A Joseph F. Ossanna
976: .%A Brian W. Kernighan
977: .%A Gunnar Ritter
978: .%T Heirloom Documentation Tools Nroff/Troff User's Manual
979: .%D September 17, 2007
980: .%U http://heirloom.sourceforge.net/doctools/troff.pdf
981: .Re
982: .Sh HISTORY
1.35 kristaps 983: The RUNOFF typesetting system, whose input forms the basis for
1.17 schwarze 984: .Nm ,
1.35 kristaps 985: was written in MAD and FAP for the CTSS operating system by Jerome E.
986: Saltzer in 1964.
987: Doug McIlroy rewrote it in BCPL in 1969, renaming it
988: .Nm .
989: Dennis M. Ritchie rewrote McIlroy's
1.36 schwarze 990: .Nm
991: in PDP-11 assembly for
1.35 kristaps 992: .At v1 ,
993: Joseph F. Ossanna improved roff and renamed it nroff
994: for
995: .At v2 ,
996: then ported nroff to C as troff, which Brian W. Kernighan released with
997: .At v7 .
998: In 1989, James Clarke re-implemented troff in C++, naming it groff.
1.1 kristaps 999: .Sh AUTHORS
1.15 kristaps 1000: .An -nosplit
1.31 kristaps 1001: This
1.1 kristaps 1002: .Nm
1003: reference was written by
1.41 schwarze 1004: .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv
1.15 kristaps 1005: and
1.41 schwarze 1006: .An Ingo Schwarze Aq Mt schwarze@openbsd.org .
CVSweb