Annotation of mandoc/roff.7, Revision 1.6
1.6 ! schwarze 1: .\" $Id: roff.7,v 1.5 2010/05/17 02:38:13 kristaps Exp $
1.1 kristaps 2: .\"
3: .\" Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
4: .\"
5: .\" Permission to use, copy, modify, and distribute this software for any
6: .\" purpose with or without fee is hereby granted, provided that the above
7: .\" copyright notice and this permission notice appear in all copies.
8: .\"
9: .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10: .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12: .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16: .\"
1.4 kristaps 17: .Dd $Mdocdate: May 17 2010 $
1.1 kristaps 18: .Dt ROFF 7
19: .Os
20: .Sh NAME
21: .Nm roff
22: .Nd roff language reference
23: .Sh DESCRIPTION
24: The
25: .Nm roff
26: language is a general-purpose text-formatting language. The purpose of
27: this document is to consistently describe those language constructs
28: accepted by the
29: .Xr mandoc 1
30: utility. It is a work in progress.
31: .Pp
32: An
33: .Nm
34: document follows simple rules: lines beginning with the control
35: characters
36: .Sq \.
37: or
38: .Sq \(aq
39: are parsed for macros. Other lines are interpreted within the scope of
40: prior macros:
41: .Bd -literal -offset indent
42: \&.xx Macro lines change control state.
43: Other lines are interpreted within the current state.
44: .Ed
45: .Sh LANGUAGE SYNTAX
46: .Nm
47: documents may contain only graphable 7-bit ASCII characters, the space
48: character, and, in certain circumstances, the tab character. All
49: manuals must have
50: .Ux
51: line terminators.
52: .Sh MACRO SYNTAX
53: Macros are arbitrary in length and begin with a control character ,
54: .Sq \.
55: or
56: .Sq \(aq ,
57: at the beginning of the line.
58: An arbitrary amount of whitespace may sit between the control character
59: and the macro name.
60: Thus, the following are equivalent:
61: .Bd -literal -offset indent
62: \&.if
63: \&.\ \ \ \&if
64: .Ed
65: .Sh REFERENCE
66: This section is a canonical reference of all macros, arranged
67: alphabetically.
1.3 kristaps 68: .Ss \&am
69: The syntax of this macro is the same as that of
70: .Sx \&ig ,
71: except that a leading argument must be specified.
72: It is ignored, as are its children.
73: .Ss \&ami
74: The syntax of this macro is the same as that of
75: .Sx \&ig ,
76: except that a leading argument must be specified.
77: It is ignored, as are its children.
78: .Ss \&am1
79: The syntax of this macro is the same as that of
80: .Sx \&ig ,
81: except that a leading argument must be specified.
82: It is ignored, as are its children.
83: .Ss \&de
84: The syntax of this macro is the same as that of
85: .Sx \&ig ,
86: except that a leading argument must be specified.
87: It is ignored, as are its children.
88: .Ss \&dei
89: The syntax of this macro is the same as that of
90: .Sx \&ig ,
91: except that a leading argument must be specified.
92: It is ignored, as are its children.
1.6 ! schwarze 93: .Ss \&ds
! 94: Define a string.
! 95: This macro is intended to have two arguments,
! 96: the name of the string to define and its content.
! 97: Currently, it is ignored including its arguments,
! 98: and the number of arguments is not checked.
1.3 kristaps 99: .Ss \&de1
100: The syntax of this macro is the same as that of
101: .Sx \&ig ,
102: except that a leading argument must be specified.
103: It is ignored, as are its children.
1.5 kristaps 104: .Ss \&el
105: The
106: .Qq else
107: half of an if/else conditional.
108: Pops a result off the stack of conditional evaluations pushed by
109: .Sx \&ie
110: and uses it as its conditional.
111: If no stack entries are present (e.g., due to no prior
112: .Sx \&ie
113: calls)
114: then false is assumed.
115: The syntax of this macro is similar to
116: .Sx \&if
117: except that the conditional is missing.
118: .Ss \&ie
119: The
120: .Qq if
121: half of an if/else conditional.
122: The result of the conditional is pushed into a stack used by subsequent
123: invocations of
124: .Sx \&el ,
125: which may be separated by any intervening input (or not exist at all).
126: Its syntax is equivalent to
127: .Sx \&if .
1.1 kristaps 128: .Ss \&if
1.3 kristaps 129: Begins a conditional that always evaluates to false.
130: If a conditional is false, its children are not processed, but are
131: syntactically interpreted to preserve the integrity of the input
132: document.
133: Thus,
134: .Pp
135: .D1 \&.if t \e .ig
136: .Pp
137: will discard the
138: .Sq \&.ig ,
139: which may lead to interesting results, but
140: .Pp
141: .D1 \&.if t \e .if t \e{\e
142: .Pp
143: will continue to syntactically interpret to the block close of the final
144: conditional.
145: Sub-conditionals, in this case, obviously inherit the truth value of
146: the parent.
147: This macro has the following syntax:
1.1 kristaps 148: .Pp
149: .Bd -literal -offset indent -compact
150: \&.if COND \e{\e
151: BODY...
152: \&.\e}
153: .Ed
154: .Bd -literal -offset indent -compact
155: \&.if COND \e{ BODY
1.2 kristaps 156: BODY... \e}
157: .Ed
158: .Bd -literal -offset indent -compact
159: \&.if COND \e{ BODY
1.1 kristaps 160: BODY...
161: \&.\e}
162: .Ed
163: .Bd -literal -offset indent -compact
164: \&.if COND \e
165: BODY
166: .Ed
167: .Pp
1.3 kristaps 168: COND is a conditional (for the time being, this always evaluates to
169: false).
1.1 kristaps 170: .Pp
171: If the BODY section is begun by an escaped brace
172: .Sq \e{ ,
173: scope continues until a closing-brace macro
174: .Sq \.\e} .
175: If the BODY is not enclosed in braces, scope continues until the next
176: macro or word.
177: If the COND is followed by a BODY on the same line, whether after a
178: brace or not, then macros
179: .Em must
180: begin with a control character.
181: It is generally more intuitive, in this case, to write
182: .Bd -literal -offset indent
183: \&.if COND \e{\e
184: \&.foo
185: bar
186: \&.\e}
187: .Ed
188: .Pp
189: than having the macro follow as
190: .Pp
191: .D1 \&.if COND \e{ .foo
192: .Pp
193: The scope of a conditional is always parsed, but only executed if the
194: conditional evaluates to true.
195: .Pp
196: Note that text subsequent a
1.2 kristaps 197: .Sq \&.\e}
198: macro is discarded.
199: Furthermore, if an explicit closing sequence
1.1 kristaps 200: .Sq \e}
1.2 kristaps 201: is specified in a free-form line, the entire line is accepted within the
202: scope of the prior macro, not only the text preceding the close.
1.1 kristaps 203: .Ss \&ig
1.2 kristaps 204: Ignore input.
205: Accepts the following syntax:
206: .Pp
207: .Bd -literal -offset indent -compact
208: \&.ig
209: BODY...
210: \&..
211: .Ed
212: .Bd -literal -offset indent -compact
213: \&.ig END
214: BODY...
215: \&.END
216: .Ed
217: .Pp
218: In the first case, input is ignored until a
219: .Sq \&..
1.1 kristaps 220: macro is encountered on its own line.
1.2 kristaps 221: In the second case, input is ignored until a
222: .Sq \&.END
223: is encountered.
224: Text subsequent the
225: .Sq \&.END
226: or
227: .Sq \&..
1.1 kristaps 228: is discarded.
1.2 kristaps 229: .Pp
230: Do not use the escape
231: .Sq \e
232: anywhere in the definition of END.
233: It causes very strange behaviour.
234: Furthermore, if you redefine a
235: .Nm
236: macro, such as
237: .Pp
238: .D1 \&.ig if
239: .Pp
240: the subsequent invocation of
241: .Sx \&if
242: will first signify the end of comment, then be invoked as a macro.
243: This behaviour really shouldn't be counted upon.
1.6 ! schwarze 244: .Ss \&rm
! 245: Remove a request, macro or string.
! 246: This macro is intended to have one argument,
! 247: the name of the request, macro or string to be undefined.
! 248: Currently, it is ignored including its arguments,
! 249: and the number of arguments is not checked.
! 250: .Ss \&tr
! 251: Output character translation.
! 252: This macro is intended to have one argument,
! 253: consisting of an even number of characters.
! 254: Currently, it is ignored including its arguments,
! 255: and the number of arguments is not checked.
1.2 kristaps 256: .Sh COMPATIBILITY
257: This section documents compatibility between mandoc and other other
258: troff implementations, at this time limited to GNU troff
259: .Pq Qq groff .
260: The term
261: .Qq historic groff
262: refers to groff versions before the
263: .Pa doc.tmac
264: file re-write
265: .Pq somewhere between 1.15 and 1.19 .
266: .Pp
267: .Bl -dash -compact
268: .It
269: Historic groff did not accept white-space buffering the custom END tag
270: for the
271: .Sx \&ig
272: macro.
1.4 kristaps 273: .It
274: The
275: .Sx \&if
276: and family would print funny white-spaces with historic groff when
277: depending on next-line syntax.
1.2 kristaps 278: .El
1.1 kristaps 279: .Sh AUTHORS
280: The
281: .Nm
282: reference was written by
283: .An Kristaps Dzonsons Aq kristaps@bsd.lv .
CVSweb