1 .\" $Id: mdoc.7,v 1.54 2009/07/27 12:35:54 kristaps Exp $
3 .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
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.
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.
17 .Dd $Mdocdate: July 27 2009 $
20 .\" SECTION---------------------------------------------
23 .Nd mdoc language reference
24 .\" SECTION---------------------------------------------
28 language is used to format
31 manuals. In this reference document, we describe its syntax, structure,
32 and usage. Our reference implementation is
36 section describes compatibility with
38 .\" PARAGRAPH------------
42 document follows simple rules: lines beginning with the control
45 are parsed for macros. Other lines are interpreted within the scope of
47 .Bd -literal -offset indent
48 \&.Sh Macro lines change control state.
49 Other lines are interpreted within the current state.
51 .\" SECTION---------------------------------------------
54 documents may contain only graphable 7-bit ASCII characters, the space
55 character, and, in certain circumstances, the tab character. All
59 .\" SUB-SECTION----------------------
63 whether in a macro or free-form text line, is ignored to the end of
64 line. A macro line with only a control character and comment escape,
67 .\" SUB-SECTION----------------------
68 .Ss Reserved Characters
69 Within a macro line, the following characters are reserved:
70 .Bl -tag -width Ds -offset indent -compact
94 .\" PARAGRAPH------------
96 Use of reserved characters is described in
98 For general use in macro lines, these characters must either be escaped
99 with a non-breaking space
101 or, if applicable, an appropriate escape sequence used.
102 .\" SUB-SECTION----------------------
103 .Ss Special Characters
104 Special characters may occur in both macro and free-form lines.
105 Sequences begin with the escape character
107 followed by either an open-parenthesis
109 for two-character sequences; an open-bracket
111 for n-character sequences (terminated at a close-bracket
113 or a single one-character sequence. See
115 for a complete list. Examples include
121 .\" SUB-SECTION----------------------
123 Terms may be text-decorated using the
125 escape followed by an indicator: B (bold), I, (italic), or P and R
126 (Roman, or reset). This form is not recommended for
128 which encourages semantic, not presentation, annotation.
129 .\" SUB-SECTION----------------------
130 .Ss Predefined Strings
133 also defined a set of package-specific
134 .Dq predefined strings ,
136 .Sx Special Characters ,
137 demark special output characters and strings by way of input codes.
138 Predefined strings are escaped with the slash-asterisk,
148 for a complete list. Examples include
154 .\" SUB-SECTION----------------------
156 In non-literal free-form lines, consecutive blocks of whitespace are
157 pruned from input and added later in the output filter, if applicable:
158 .Bd -literal -offset indent
159 These spaces are pruned from input.
164 .\" PARAGRAPH------------
166 In macro lines, whitespace delimits arguments and is discarded. If
167 arguments are quoted, whitespace within the quotes is retained.
168 .\" PARAGRAPH------------
170 Blank lines are only permitted within literal contexts, as are lines
171 containing only whitespace. Tab characters are only acceptable when
174 or when in a literal context.
175 .\" SUB-SECTION----------------------
177 Macro arguments may be quoted with a double-quote to group
178 space-delimited terms or to retain blocks of whitespace. A quoted
179 argument begins with a double-quote preceded by whitespace. The next
180 double-quote not pair-wise adjacent to another double-quote terminates
181 the literal, regardless of surrounding whitespace.
182 .\" PARAGRAPH------------
190 Note that any quoted term, be it argument or macro, is indiscriminately
191 considered literal text. Thus, the following produces
193 .Bd -literal -offset indent
196 .\" PARAGRAPH------------
198 In free-form mode, quotes are regarded as opaque text.
199 .\" SECTION---------------------------------------------
203 document must begin with a document prologue, containing, in order,
208 then the NAME section containing at least one
212 .Bd -literal -offset indent
218 \&.Nd mdoc language reference
220 .\" PARAGRAPH------------
222 Subsequent SYNOPSIS and DESCRIPTION sections are strongly encouraged,
224 .\" SECTION---------------------------------------------
226 Every line beginning with the control character
228 is processed for macros, two- or three-character sequences.
229 .\" PARAGRAPH------------
231 The syntax of a macro depends on its classification. In this section,
233 refers to macro arguments, which may be followed by zero or more
237 opens the scope of a macro; and if specified,
240 .\" PARAGRAPH------------
244 column indicates that the macro may be called subsequent to the initial
247 column indicates whether the macro may be followed by further
248 (ostensibly callable) macros. The
250 column, if applicable, describes closure rules.
251 .\" SUB-SECTION----------------------
252 .Ss Block full-explicit
253 Multi-line scope closed by an explicit closing macro. All macros
254 contains bodies; only
257 .Bd -literal -offset indent
258 \&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead...\(rB
262 .\" PARAGRAPH------------
264 .Bl -column -compact -offset indent "MacroX" "CallableX" "ParsableX" "closed by XXX"
265 .It Em Macro Ta Em Callable Ta Em Parsable Ta Em Scope
266 .It \&Bd Ta \&No Ta \&No Ta closed by \&Ed
267 .It \&Bf Ta \&No Ta \&No Ta closed by \&Ef
268 .It \&Bk Ta \&No Ta \&No Ta closed by \&Ek
269 .It \&Bl Ta \&No Ta \&No Ta closed by \&El
270 .It \&Ed Ta \&No Ta \&No Ta opened by \&Bd
271 .It \&Ef Ta \&No Ta \&No Ta opened by \&Bf
272 .It \&Ek Ta \&No Ta \&No Ta opened by \&Bk
273 .It \&El Ta \&No Ta \&No Ta opened by \&Bl
275 .\" SUB-SECTION----------------------
276 .Ss Block full-implicit
277 Multi-line scope closed by end-of-file or implicitly by another macro.
278 All macros have bodies; some
286 don't have heads, while
288 may have multiple heads.
289 .Bd -literal -offset indent
290 \&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead... \(lBTa head...\(rB\(rB
293 .\" PARAGRAPH------------
295 .Bl -column -compact -offset indent "MacroX" "CallableX" "ParsableX" "closed by XXXXXXXXXXX"
296 .It Em Macro Ta Em Callable Ta Em Parsable Ta Em Scope
297 .It \&It Ta \&No Ta Yes Ta closed by \&It, \&El
298 .It \&Nd Ta \&No Ta \&No Ta closed by \&Sh
299 .It \&Sh Ta \&No Ta \&No Ta closed by \&Sh
300 .It \&Ss Ta \&No Ta \&No Ta closed by \&Sh, \&Ss
302 .\" SUB-SECTION----------------------
303 .Ss Block partial-explicit
304 Like block full-explicit, but also with single-line scope. Each
305 has at least a body and, in limited circumstances, a head
306 .Pq So \&Fo Sc , So \&Eo Sc
309 .Bd -literal -offset indent
310 \&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead...\(rB
312 \&.Yc \(lBtail...\(rB
314 \&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead...\(rB \
315 \(lBbody...\(rB \&Yc \(lBtail...\(rB
317 .\" PARAGRAPH------------
319 .Bl -column "MacroX" "CallableX" "ParsableX" "closed by XXXX" -compact -offset indent
320 .It Em Macro Ta Em Callable Ta Em Parsable Ta Em Scope
321 .It \&Ac Ta Yes Ta Yes Ta opened by \&Ao
322 .It \&Ao Ta Yes Ta Yes Ta closed by \&Ac
323 .It \&Bc Ta Yes Ta Yes Ta closed by \&Bo
324 .It \&Bo Ta Yes Ta Yes Ta opened by \&Bc
325 .It \&Brc Ta Yes Ta Yes Ta opened by \&Bro
326 .It \&Bro Ta Yes Ta Yes Ta closed by \&Brc
327 .It \&Dc Ta Yes Ta Yes Ta opened by \&Do
328 .It \&Do Ta Yes Ta Yes Ta closed by \&Dc
329 .It \&Ec Ta Yes Ta Yes Ta opened by \&Eo
330 .It \&Eo Ta Yes Ta Yes Ta closed by \&Ec
331 .It \&Fc Ta Yes Ta Yes Ta opened by \&Fo
332 .It \&Fo Ta \&No Ta \&No Ta closed by \&Fc
333 .It \&Oc Ta Yes Ta Yes Ta closed by \&Oo
334 .It \&Oo Ta Yes Ta Yes Ta opened by \&Oc
335 .It \&Pc Ta Yes Ta Yes Ta closed by \&Po
336 .It \&Po Ta Yes Ta Yes Ta opened by \&Pc
337 .It \&Qc Ta Yes Ta Yes Ta opened by \&Oo
338 .It \&Qo Ta Yes Ta Yes Ta closed by \&Oc
339 .It \&Re Ta \&No Ta \&No Ta opened by \&Rs
340 .It \&Rs Ta \&No Ta \&No Ta closed by \&Re
341 .It \&Sc Ta Yes Ta Yes Ta opened by \&So
342 .It \&So Ta Yes Ta Yes Ta closed by \&Sc
343 .It \&Xc Ta Yes Ta Yes Ta opened by \&Xo
344 .It \&Xo Ta Yes Ta Yes Ta closed by \&Xc
346 .\" SUB-SECTION----------------------
347 .Ss Block partial-implicit
348 Like block full-implicit, but with single-line scope closed by
349 .Sx Reserved Characters
351 .Bd -literal -offset indent
352 \&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBbody...\(rB \(lBres...\(rB
354 .\" PARAGRAPH------------
356 .Bl -column "MacroX" "CallableX" "ParsableX" -compact -offset indent
357 .It Em Macro Ta Em Callable Ta Em Parsable
358 .It \&Aq Ta Yes Ta Yes
359 .It \&Bq Ta Yes Ta Yes
360 .It \&Brq Ta Yes Ta Yes
361 .It \&D1 Ta \&No Ta \&Yes
362 .It \&Dl Ta \&No Ta Yes
363 .It \&Dq Ta Yes Ta Yes
364 .It \&Op Ta Yes Ta Yes
365 .It \&Pq Ta Yes Ta Yes
366 .It \&Ql Ta Yes Ta Yes
367 .It \&Qq Ta Yes Ta Yes
368 .It \&Sq Ta Yes Ta Yes
370 .\" SUB-SECTION----------------------
373 .Sx Reserved Characters ,
374 end of line, fixed argument lengths, and/or subsequent macros. In-line
375 macros have only text children. If a number (or inequality) of
378 then the macro accepts an arbitrary number of arguments.
379 .Bd -literal -offset indent
380 \&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBargs...\(rB \(lbres...\(rb
382 \&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBargs...\(rB Yc...
384 \&.Yo \(lB\-arg \(lBval...\(rB\(rB arg0 arg1 argN
386 .\" PARAGRAPH------------
388 .Bl -column "MacroX" "CallableX" "ParsableX" "Arguments" -compact -offset indent
389 .It Em Macro Ta Em Callable Ta Em Parsable Ta Em Arguments
390 .It \&%A Ta \&No Ta \&No Ta >0
391 .It \&%B Ta \&No Ta \&No Ta >0
392 .It \&%C Ta \&No Ta \&No Ta >0
393 .It \&%D Ta \&No Ta \&No Ta >0
394 .It \&%I Ta \&No Ta \&No Ta >0
395 .It \&%J Ta \&No Ta \&No Ta >0
396 .It \&%N Ta \&No Ta \&No Ta >0
397 .It \&%O Ta \&No Ta \&No Ta >0
398 .It \&%P Ta \&No Ta \&No Ta >0
399 .It \&%R Ta \&No Ta \&No Ta >0
400 .It \&%T Ta \&No Ta \&No Ta >0
401 .It \&%V Ta \&No Ta \&No Ta >0
402 .It \&Ad Ta Yes Ta Yes Ta n
403 .It \&An Ta Yes Ta Yes Ta n
404 .It \&Ap Ta Yes Ta Yes Ta 0
405 .It \&Ar Ta Yes Ta Yes Ta n
406 .It \&At Ta Yes Ta Yes Ta 1
407 .It \&Bsx Ta Yes Ta Yes Ta n
408 .It \&Bt Ta \&No Ta \&No Ta 0
409 .It \&Bx Ta Yes Ta Yes Ta n
410 .It \&Cd Ta Yes Ta Yes Ta >0
411 .It \&Cm Ta Yes Ta Yes Ta n
412 .It \&Db Ta \&No Ta \&No Ta 1
413 .It \&Dd Ta \&No Ta \&No Ta >0
414 .It \&Dt Ta \&No Ta \&No Ta n
415 .It \&Dv Ta Yes Ta Yes Ta n
416 .It \&Dx Ta Yes Ta Yes Ta n
417 .It \&Em Ta Yes Ta Yes Ta >0
418 .It \&En Ta \&No Ta \&No Ta 0
419 .It \&Er Ta Yes Ta Yes Ta >0
420 .It \&Es Ta \&No Ta \&No Ta 0
421 .It \&Ev Ta Yes Ta Yes Ta n
422 .It \&Ex Ta \&No Ta \&No Ta 0
423 .It \&Fa Ta Yes Ta Yes Ta n
424 .It \&Fd Ta \&No Ta \&No Ta >0
425 .It \&Fl Ta Yes Ta Yes Ta n
426 .It \&Fn Ta Yes Ta Yes Ta >0
427 .It \&Fr Ta \&No Ta \&No Ta n
428 .It \&Ft Ta Yes Ta Yes Ta n
429 .It \&Fx Ta Yes Ta Yes Ta n
430 .It \&Hf Ta \&No Ta \&No Ta n
431 .It \&Ic Ta Yes Ta Yes Ta >0
432 .It \&In Ta \&No Ta \&No Ta n
433 .It \&Lb Ta \&No Ta \&No Ta 1
434 .It \&Li Ta Yes Ta Yes Ta n
435 .It \&Lk Ta Yes Ta Yes Ta n
436 .It \&Lp Ta \&No Ta \&No Ta 0
437 .It \&Ms Ta Yes Ta Yes Ta >0
438 .It \&Mt Ta Yes Ta Yes Ta >0
439 .It \&Nm Ta Yes Ta Yes Ta n
440 .It \&No Ta Yes Ta Yes Ta 0
441 .It \&Ns Ta Yes Ta Yes Ta 0
442 .It \&Nx Ta Yes Ta Yes Ta n
443 .It \&Os Ta \&No Ta \&No Ta n
444 .It \&Ot Ta \&No Ta \&No Ta n
445 .It \&Ox Ta Yes Ta Yes Ta n
446 .It \&Pa Ta Yes Ta Yes Ta n
447 .It \&Pf Ta \&No Ta Yes Ta 1
448 .It \&Pp Ta \&No Ta \&No Ta 0
449 .It \&Rv Ta \&No Ta \&No Ta 0
450 .It \&Sm Ta \&No Ta \&No Ta 1
451 .It \&St Ta \&No Ta Yes Ta 1
452 .It \&Sx Ta Yes Ta Yes Ta >0
453 .It \&Sy Ta Yes Ta Yes Ta >0
454 .It \&Tn Ta Yes Ta Yes Ta >0
455 .It \&Ud Ta \&No Ta \&No Ta 0
456 .It \&Ux Ta Yes Ta Yes Ta n
457 .It \&Va Ta Yes Ta Yes Ta n
458 .It \&Vt Ta Yes Ta Yes Ta >0
459 .It \&Xr Ta Yes Ta Yes Ta >0, <3
460 .It \&br Ta \&No Ta \&No Ta 0
461 .It \&sp Ta \&No Ta \&No Ta 1
463 .\" SECTION---------------------------------------------
465 This section documents compatibility with other roff implementations, at
470 refers to those versions before the
473 .Pq somewhere between 1.15 and 1.19 .
474 .\" PARAGRAPH------------
485 applies to the whole document, not just to the current section as it
489 In quoted literals, groff allowed pair-wise double-quotes to produce a
490 standalone double-quote in formatted output. This idiosyncratic
491 behaviour is no longer applicable.
496 macro does not accept negative numbers.
499 Blocks of whitespace are stripped from both macro and free-form text
500 lines (except when in literal mode), while groff would retain whitespace
501 in free-form text lines.
504 Historic groff has many un-callable macros. Most of these (excluding
505 some block-level macros) are now callable, conforming to the
506 non-historic groff version.
513 but is a proper delimiter in this implementation.
517 is assumed for all lists (it wasn't in historic groff): any list may be
520 lists will restart the sequence only for the sub-list.
524 syntax where column widths may be preceded by other arguments (instead
525 of proceeded) is not supported.
530 macro only accepts a single parameter.
535 incorrectly by following it with a reserved character and expecting the
536 delimiter to render. This is not supported.
541 macro only produces the first parameter. This is no longer the case.
543 .\" SECTION---------------------------------------------
547 .\" SECTION---------------------------------------------
551 reference was written by
552 .An Kristaps Dzonsons Aq kristaps@kth.se .
553 .\" SECTION---------------------------------------------
555 There are many ambiguous parts of mdoc.
556 .\" PARAGRAPH------------
564 as function arguments are variables.
570 as function return types are still types. Furthermore, the
572 should be removed and
574 which ostensibly follows it, should follow the same convention as
579 should formalise that only one or two arguments are acceptable: a
580 variable name and optional, preceding type.
584 is ambiguous. It's commonly used to indicate an include file in the
587 should be used, instead.
594 makes sense. The remaining ones should be removed.
601 macros should be deprecated.
606 macro lacks clarity. It should be absolutely clear which title will
607 render when formatting the manual page.
612 should be provided for Linux (\(`a la
618 There's no way to refer to references in
623 The \-split and \-nosplit dictates via
625 are re-set when entering and leaving the AUTHORS section.