1 .\" $Id: mdoc.7,v 1.19 2009/03/27 14:56:15 kristaps Exp $
3 .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the
7 .\" above copyright notice and this permission notice appear in all
10 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 .\" WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 .\" AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 .\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 .\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 .\" PERFORMANCE OF THIS SOFTWARE.
19 .Dd $Mdocdate: March 27 2009 $
25 .Nd mdoc language reference
30 language is used to format
33 manuals. In this reference document, we describe the syntax, ontology
41 document follows simple rules: lines beginning with the control
44 are parsed for macros. Other lines are interpreted within the scope of
46 .Bd -literal -offset XXX
47 \&.Sh Macro lines change control state.
48 Other lines are interpreted within the current state.
53 documents may contain only graphable 7-bit ASCII characters, the space
56 and, in certain circumstances, the tab character
62 The only time a blank line is acceptable is within
66 .Sq \&.Bd \-unfilled .
70 are only acceptable when delimiting
78 .Ss Reserved Characters
79 Within a macro line, the following characters are reserved:
80 .Bl -tag -width 12n -offset XXXX -compact
104 Use of reserved characters is described in
106 For general non-reserved use, characters must either be escaped with a
109 or, if applicable, an appropriate escape-sequence used.
111 .Ss Special Characters
112 Special character sequences begin with the escape character
114 followed by either an open-parenthesis
116 for two-character sequences; an open-bracket
118 for n-character sequences (terminated at a close-bracket
120 or a single one-character sequence.
122 Characters may alternatively be escaped by a slash-asterisk,
124 with the same combinations as described above. This form is deprecated.
127 Macros are classified in an ontology described by their scope rules.
128 Some macros are allowed to deviate from their classifications to
129 preserve backward-compatibility with old macro combinations still found
130 in the manual corpus. These are specifically noted on a per-macro
137 macros enclose other block macros, in-line macros or text, and
138 may span multiple lines.
139 .Bl -inset -offset XXXX
142 macros always span multiple lines. They consist of zero or
145 subsequent macros or text on the same line following invocation; an
148 which spans subsequent lines of text or macros; and an optional
150 macros or text on the same line following closure.
153 macros may span multiple lines. They consists of a optional
155 text immediately following invocation; always a
157 text or macros following the head on the same and subsequent lines; and
160 text immediately following closure.
163 macros may only enclose text and span at most a single line.
168 Closure of a macro's scope depends first on its classification, then
169 on whether it's parsable. In this table,
171 refers to block full-explicit and so on.
174 .Bl -tag -width 12n -offset XXXX -compact
176 corresponding explicit closure macro
178 end-of-file or a corresponding implicit closure macro
180 end-of-line (body may be closed by >0 space-separated
181 .Sx Reserved Characters ,
182 although block scope will still be open)
188 If a macro (block or in-line) is parsable, it may also be closed out by
189 one of the following scenarios (unless specifically noted otherwise):
192 .Bl -dash -offset XXXX -compact
194 a sequence of >0 space-separated
195 .Sx Reserved Characters ,
201 completion of a set number of arguments.
205 If >0 space-separated
206 .Sx Reserved Characters
207 are followed by non-reserved characters, the behaviour differs per
208 macro. In general, scope of the macro is closed and re-opened:
209 subsequent tokens are interpreted as if the scope had just been opened.
210 In other circumstances, scope is simply closed out.
213 Macros are two or three characters in length. The syntax of macro
214 invocation depends on its classification.
216 refers to the macro arguments (which may contain zero or more values).
217 In these illustrations,
219 opens the scope of a macro, and if specified,
221 closes it out (closure may be implicit at end-of-line or end-of-file).
224 Block full-explicit (may contain head, body, tail).
225 .Bd -literal -offset XXXX
226 \&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBhead...\(rB
228 \&.Yc \(lBtail...\(rB
232 Block full-implicit (may contain zero or more heads, body, no tail).
233 .Bd -literal -offset XXXX
234 \&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBhead... \(lBTa head...\(rB\(rB
240 Block partial-explicit (may contain head, multi-line body, tail).
241 .Bd -literal -offset XXXX
242 \&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBhead...\(rB
244 \&.Yc \(lBtail...\(rB
246 \&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBhead...\(rB \
247 \(lBbody...\(rB \&Yc \(lBtail...\(rB
251 Block partial-implicit (no head, body, no tail). Note that the body
252 section may be followed by zero or more
254 These are in the block scope, but not in the body scope.
255 .Bd -literal -offset XXXX
256 \&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBbody...\(rB \(lBreserved...\(rB
260 In-lines have \(>=0 scoped arguments.
261 .Bd -literal -offset XXX
262 \&.Yy \(lB\-arg \(lBval...\(rB\(rB \(lBargs...\(rB
264 \&.Yy \(lB\-arg \(lBval...\(rB\(rB arg0 arg1 argN
268 This section contains a complete list of all
270 macros, arranged ontologically. A
272 macro is invoked subsequent to the initial macro-line macro. A
274 macro may be followed by further (ostensibly callable) macros.
276 .Ss Block full-implicit
277 The head of these macros follows invocation; the body is the content of
278 subsequent lines prior to closure. None of these macros have tails;
289 .Bl -column "MacroX" "CallableX" "ParsableX" "Closing" -compact -offset XXXX
290 .It Em Macro Ta Em Callable Ta Em Parsable Ta Em Closing
291 .It \&.Sh Ta \&No Ta \&No Ta \&.Sh
292 .It \&.Ss Ta \&No Ta \&No Ta \&.Sh, \&.Ss
293 .It \&.It Ta \&No Ta Yes Ta \&.It, \&.El
296 .Ss Block full-explicit
297 None of these macros are callable or parsed. The last column indicates
298 the explicit scope rules. All contains bodies, some may contain heads
301 .Bl -column "MacroX" "CallableX" "ParsableX" "closed by XXX" -compact -offset XXXX
302 .It Em Macro Ta Em Callable Ta Em Parsable Ta Em Scope
303 .It \&.Bd Ta \&No Ta \&No Ta closed by \&.Ed
304 .It \&.Ed Ta \&No Ta \&No Ta opened by \&.Bd
305 .It \&.Bl Ta \&No Ta \&No Ta closed by \&.El
306 .It \&.El Ta \&No Ta \&No Ta opened by \&.Bl
307 .It \&.Bf Ta \&No Ta \&No Ta closed by \&.Ef
308 .It \&.Ef Ta \&No Ta \&No Ta opened by \&.Bf
309 .It \&.Bk Ta \&No Ta \&No Ta closed by \&.Ek
310 .It \&.Ek Ta \&No Ta \&No Ta opened by \&.Bk
313 .Ss Block partial-implicit
314 All of these are callable and parsed for further macros. Their scopes
315 close at the invocation's end-of-line.
317 .Bl -column "MacroX" "CallableX" "ParsableX" -compact -offset XXXX
318 .It Em Macro Ta Em Callable Ta Em Parsable
319 .It \&.Aq Ta Yes Ta Yes
320 .It \&.Op Ta Yes Ta Yes
321 .It \&.Bq Ta Yes Ta Yes
322 .It \&.Dq Ta Yes Ta Yes
323 .It \&.Pq Ta Yes Ta Yes
324 .It \&.Qq Ta Yes Ta Yes
325 .It \&.Sq Ta Yes Ta Yes
326 .It \&.Brq Ta Yes Ta Yes
327 .It \&.D1 Ta \&No Ta \&Yes
328 .It \&.Dl Ta \&No Ta Yes
329 .It \&.Ql Ta Yes Ta Yes
337 as in the following example:
338 .Bd -literal -offset XXXX
343 In the above example, the scope of
345 is technically broken by
347 however, due to the overwhelming existence of this sequence, it's
350 .Ss Block partial-explicit
351 Each of these contains at least a body and, in limited circumstances, a
353 .Pq So \&.Fo Sc , So \&.Eo Sc
357 .Bl -column "MacroX" "CallableX" "ParsableX" "closed by XXXX" -compact -offset XXXX
358 .It Em Macro Ta Em Callable Ta Em Parsable Ta Em Scope
359 .It \&.Ao Ta Yes Ta Yes Ta closed by \&.Ac
360 .It \&.Ac Ta Yes Ta Yes Ta opened by \&.Ao
361 .It \&.Bc Ta Yes Ta Yes Ta closed by \&.Bo
362 .It \&.Bo Ta Yes Ta Yes Ta opened by \&.Bc
363 .It \&.Pc Ta Yes Ta Yes Ta closed by \&.Po
364 .It \&.Po Ta Yes Ta Yes Ta opened by \&.Pc
365 .It \&.Do Ta Yes Ta Yes Ta closed by \&.Dc
366 .It \&.Dc Ta Yes Ta Yes Ta opened by \&.Do
367 .It \&.Xo Ta Yes Ta Yes Ta closed by \&.Xc
368 .It \&.Xc Ta Yes Ta Yes Ta opened by \&.Xo
369 .It \&.Bro Ta Yes Ta Yes Ta closed by \&.Brc
370 .It \&.Brc Ta Yes Ta Yes Ta opened by \&.Bro
371 .It \&.Oc Ta Yes Ta Yes Ta closed by \&.Oo
372 .It \&.Oo Ta Yes Ta Yes Ta opened by \&.Oc
373 .It \&.So Ta Yes Ta Yes Ta closed by \&.Sc
374 .It \&.Sc Ta Yes Ta Yes Ta opened by \&.So
375 .It \&.Fc Ta Yes Ta Yes Ta opened by \&.Fo
376 .It \&.Fo Ta \&No Ta \&No Ta closed by \&.Fc
377 .It \&.Ec Ta Yes Ta Yes Ta opened by \&.Eo
378 .It \&.Eo Ta Yes Ta Yes Ta closed by \&.Ec
379 .It \&.Qc Ta Yes Ta Yes Ta opened by \&.Oo
380 .It \&.Qo Ta Yes Ta Yes Ta closed by \&.Oc
381 .It \&.Re Ta \&No Ta \&No Ta opened by \&.Rs
382 .It \&.Rs Ta \&No Ta \&No Ta closed by \&.Re
386 In-line macros have only text children. If a number (or inequality) of
389 then the macro accepts an arbitrary number of arguments.
391 .Bl -column "MacroX" "CallableX" "ParsableX" "Arguments" -compact -offset XXXX
392 .It Em Macro Ta Em Callable Ta Em Parsable Ta Em Arguments
393 .It \&.Dd Ta \&No Ta \&No Ta >0
394 .It \&.Dt Ta \&No Ta \&No Ta n
395 .It \&.Os Ta \&No Ta \&No Ta n
396 .It \&.Pp Ta \&No Ta \&No Ta 0
397 .It \&.Ad Ta Yes Ta Yes Ta n
398 .It \&.An Ta \&No Ta Yes Ta n
399 .It \&.Ar Ta Yes Ta Yes Ta n
400 .It \&.Cd Ta Yes Ta \&No Ta >0
401 .It \&.Cm Ta Yes Ta Yes Ta n
402 .It \&.Dv Ta Yes Ta Yes Ta n
403 .It \&.Er Ta Yes Ta Yes Ta >0
404 .It \&.Ev Ta Yes Ta Yes Ta n
405 .It \&.Ex Ta \&No Ta \&No Ta 0
406 .It \&.Fa Ta Yes Ta Yes Ta n
407 .It \&.Fd Ta \&No Ta \&No Ta >0
408 .It \&.Fl Ta Yes Ta Yes Ta n
409 .It \&.Fn Ta Yes Ta Yes Ta >0
410 .It \&.Ft Ta \&No Ta Yes Ta n
411 .It \&.Ic Ta Yes Ta Yes Ta >0
412 .It \&.In Ta \&No Ta \&No Ta n
413 .It \&.Li Ta Yes Ta Yes Ta n
414 .It \&.Nd Ta \&No Ta \&No Ta n
415 .It \&.Nm Ta Yes Ta Yes Ta n
416 .It \&.Ot Ta \&No Ta \&No Ta n
417 .It \&.Pa Ta Yes Ta Yes Ta n
418 .It \&.Rv Ta \&No Ta \&No Ta 0
419 .It \&.St Ta \&No Ta Yes Ta 1
420 .It \&.Va Ta Yes Ta Yes Ta n
421 .It \&.Vt Ta Yes Ta Yes Ta >0
422 .It \&.Xr Ta Yes Ta Yes Ta >0, <3
423 .It \&.%A Ta \&No Ta \&No Ta >0
424 .It \&.%B Ta \&No Ta \&No Ta >0
425 .It \&.%C Ta \&No Ta \&No Ta >0
426 .It \&.%D Ta \&No Ta \&No Ta >0
427 .It \&.%I Ta \&No Ta \&No Ta >0
428 .It \&.%J Ta \&No Ta \&No Ta >0
429 .It \&.%N Ta \&No Ta \&No Ta >0
430 .It \&.%O Ta \&No Ta \&No Ta >0
431 .It \&.%P Ta \&No Ta \&No Ta >0
432 .It \&.%R Ta \&No Ta \&No Ta >0
433 .It \&.%T Ta \&No Ta \&No Ta >0
434 .It \&.%V Ta \&No Ta \&No Ta >0
435 .It \&.At Ta Yes Ta Yes Ta 1
436 .It \&.Bsx Ta Yes Ta Yes Ta n
437 .It \&.Bx Ta Yes Ta Yes Ta n
438 .It \&.Db Ta \&No Ta \&No Ta 1
439 .It \&.Em Ta Yes Ta Yes Ta >0
440 .It \&.Fx Ta Yes Ta Yes Ta n
441 .It \&.Ms Ta \&No Ta Yes Ta >0
442 .It \&.No Ta Yes Ta Yes Ta 0
443 .It \&.Ns Ta Yes Ta Yes Ta 0
444 .It \&.Nx Ta Yes Ta Yes Ta n
445 .It \&.Ox Ta Yes Ta Yes Ta n
446 .It \&.Pf Ta \&No Ta Yes Ta 1
447 .It \&.Sm Ta \&No Ta \&No Ta 1
448 .It \&.Sx Ta Yes Ta Yes Ta >0
449 .It \&.Sy Ta Yes Ta Yes Ta >0
450 .It \&.Tn Ta Yes Ta Yes Ta >0
451 .It \&.Ux Ta Yes Ta Yes Ta n
452 .It \&.Dx Ta Yes Ta Yes Ta n
453 .It \&.Bt Ta \&No Ta \&No Ta 0
454 .It \&.Hf Ta \&No Ta \&No Ta n
455 .It \&.Fr Ta \&No Ta \&No Ta n
456 .It \&.Ud Ta \&No Ta \&No Ta 0
457 .It \&.Lb Ta \&No Ta \&No Ta 1
458 .It \&.Ap Ta Yes Ta Yes Ta 0
459 .It \&.Lp Ta \&No Ta \&No Ta 0
460 .It \&.Lk Ta \&No Ta Yes Ta >0
461 .It \&.Mt Ta \&No Ta Yes Ta >0
462 .It \&.Es Ta \&No Ta \&No Ta 0
463 .It \&.En Ta \&No Ta \&No Ta 0
475 The mdoc language was traditionally a
477 macro package; most existing manuals were written with mdoc syntax
478 dictated by system-dependent roff installations. This section documents
479 compatibility with these systems.
487 historically weren't always callable. Both are now correctly callable.
491 is assumed for all lists: any list may be nested and
493 lists will restart the sequence only for the sub-list.
497 syntax where column widths may be preceeded by other arguments (instead
498 of proceeded) is not supported.
503 macro only accepts a single parameter.
506 The system-name macros (
520 incorrectly by following it with a reserved character and expecting the
521 delimiter to render. This is not supported.
535 utility was written by
536 .An Kristaps Dzonsons Aq kristaps@openbsd.org .
539 There are several ambiguous parts of mdoc.
547 as function arguments are variables.
553 as function return types are still types. Furthermore, the
555 should be removed and
557 which ostensibly follows it, should follow the same convention as
562 should formalise that only one or two arguments are acceptable: a
563 variable name and optional, preceeding type.
567 is ambiguous. It's commonly used to indicate an include file in the
570 should be used, instead.
577 makes sense. The remaining ones should be removed.
584 macros should be deprecated.
589 macro lacks clarity. It should be absolutely clear which title will
590 render when formatting the manual page.
595 should be provided for Linux (\(`a la
601 There's no way to refer to references in