Annotation of mandoc/mandoc.1, Revision 1.58
1.58 ! kristaps 1: .\" $Id: mandoc.1,v 1.57 2010/04/08 07:40:03 kristaps Exp $
1.1 kristaps 2: .\"
1.17 kristaps 3: .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
1.1 kristaps 4: .\"
5: .\" Permission to use, copy, modify, and distribute this software for any
1.16 kristaps 6: .\" purpose with or without fee is hereby granted, provided that the above
7: .\" copyright notice and this permission notice appear in all copies.
1.1 kristaps 8: .\"
1.16 kristaps 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.
1.1 kristaps 16: .\"
1.58 ! kristaps 17: .Dd $Mdocdate: April 8 2010 $
1.14 kristaps 18: .Dt MANDOC 1
1.1 kristaps 19: .Os
1.32 kristaps 20: .
21: .
1.1 kristaps 22: .Sh NAME
23: .Nm mandoc
1.8 kristaps 24: .Nd format and display UNIX manuals
1.32 kristaps 25: .
26: .
1.1 kristaps 27: .Sh SYNOPSIS
28: .Nm mandoc
1.58 ! kristaps 29: .Op Fl V
! 30: .Op Fl f Ns Ar option
1.8 kristaps 31: .Op Fl m Ns Ar format
1.58 ! kristaps 32: .Op Fl O Ns Ar option
1.37 kristaps 33: .Op Fl T Ns Ar output
1.58 ! kristaps 34: .Op Fl W Ns Ar err
! 35: .Op Ar file...
1.32 kristaps 36: .
37: .
1.1 kristaps 38: .Sh DESCRIPTION
39: The
40: .Nm
1.26 kristaps 41: utility formats
1.8 kristaps 42: .Ux
1.57 kristaps 43: manual pages for display.
44: The arguments are as follows:
1.32 kristaps 45: .
1.19 kristaps 46: .Bl -tag -width Ds
1.58 ! kristaps 47: .It Fl f Ns Ar option
1.57 kristaps 48: Comma-separated compiler options.
49: See
1.1 kristaps 50: .Sx Compiler Options
51: for details.
1.32 kristaps 52: .
1.19 kristaps 53: .It Fl m Ns Ar format
1.57 kristaps 54: Input format.
55: See
1.8 kristaps 56: .Sx Input Formats
1.57 kristaps 57: for available formats.
58: Defaults to
1.58 ! kristaps 59: .Fl m Ns Cm andoc .
1.32 kristaps 60: .
1.58 ! kristaps 61: .It Fl O Ns Ar option
1.57 kristaps 62: Comma-separated output options.
63: See
1.37 kristaps 64: .Sx Output Options
65: for details.
66: .
1.19 kristaps 67: .It Fl T Ns Ar output
1.57 kristaps 68: Output format.
69: See
1.1 kristaps 70: .Sx Output Formats
1.57 kristaps 71: for available formats.
72: Defaults to
1.58 ! kristaps 73: .Fl T Ns Cm ascii .
1.32 kristaps 74: .
1.1 kristaps 75: .It Fl V
76: Print version and exit.
1.32 kristaps 77: .
1.58 ! kristaps 78: .It Fl W Ns Ar err
1.57 kristaps 79: Comma-separated warning options.
80: Use
1.58 ! kristaps 81: .Fl W Ns Cm all
1.24 kristaps 82: to print warnings,
1.58 ! kristaps 83: .Fl W Ns Cm error
1.24 kristaps 84: for warnings to be considered errors and cause utility
1.57 kristaps 85: termination.
86: Multiple
1.1 kristaps 87: .Fl W
88: arguments may be comma-separated, such as
1.58 ! kristaps 89: .Fl W Ns Cm error , Ns Cm all .
1.32 kristaps 90: .
1.58 ! kristaps 91: .It Ar file
! 92: Read input from zero or more files.
1.57 kristaps 93: If unspecified, reads from stdin.
94: If multiple files are specified,
1.2 kristaps 95: .Nm
96: will halt with the first failed parse.
1.1 kristaps 97: .El
1.32 kristaps 98: .
1.1 kristaps 99: .Pp
1.26 kristaps 100: By default,
101: .Nm
102: reads
1.8 kristaps 103: .Xr mdoc 7
1.12 kristaps 104: or
105: .Xr man 7
1.8 kristaps 106: text from stdin, implying
1.58 ! kristaps 107: .Fl m Ns Cm andoc ,
1.48 kristaps 108: and produces
1.58 ! kristaps 109: .Fl T Ns Cm ascii
1.48 kristaps 110: output.
1.32 kristaps 111: .
1.1 kristaps 112: .Pp
113: .Ex -std mandoc
1.32 kristaps 114: .
115: .
1.8 kristaps 116: .Ss Input Formats
117: The
118: .Nm
119: utility accepts
120: .Xr mdoc 7
121: and
122: .Xr man 7
123: input with
1.58 ! kristaps 124: .Fl m Ns Cm doc
1.8 kristaps 125: and
1.58 ! kristaps 126: .Fl m Ns Cm an ,
1.57 kristaps 127: respectively.
128: The
1.8 kristaps 129: .Xr mdoc 7
130: format is
131: .Em strongly
1.26 kristaps 132: recommended;
1.8 kristaps 133: .Xr man 7
134: should only be used for legacy manuals.
1.32 kristaps 135: .
1.11 kristaps 136: .Pp
1.12 kristaps 137: A third option,
1.58 ! kristaps 138: .Fl m Ns Cm andoc ,
1.13 kristaps 139: which is also the default, determines encoding on-the-fly: if the first
1.26 kristaps 140: non-comment macro is
1.27 kristaps 141: .Sq \&Dd
1.13 kristaps 142: or
1.27 kristaps 143: .Sq \&Dt ,
1.26 kristaps 144: the
1.13 kristaps 145: .Xr mdoc 7
146: parser is used; otherwise, the
147: .Xr man 7
148: parser is used.
1.32 kristaps 149: .
1.13 kristaps 150: .Pp
151: If multiple
1.26 kristaps 152: files are specified with
1.58 ! kristaps 153: .Fl m Ns Cm andoc ,
1.57 kristaps 154: each has its file-type determined this way.
155: If multiple files are
1.13 kristaps 156: specified and
1.58 ! kristaps 157: .Fl m Ns Cm doc
1.12 kristaps 158: or
1.58 ! kristaps 159: .Fl m Ns Cm an
1.12 kristaps 160: is specified, then this format is used exclusively.
1.32 kristaps 161: .
162: .
1.1 kristaps 163: .Ss Output Formats
164: The
165: .Nm
166: utility accepts the following
167: .Fl T
1.48 kristaps 168: arguments (see
169: .Sx OUTPUT ) :
1.32 kristaps 170: .
1.19 kristaps 171: .Bl -tag -width Ds
1.58 ! kristaps 172: .It Fl T Ns Cm ascii
1.1 kristaps 173: Produce 7-bit ASCII output, backspace-encoded for bold and underline
1.57 kristaps 174: styles.
175: This is the default.
176: See
1.48 kristaps 177: .Sx ASCII Output .
1.32 kristaps 178: .
1.58 ! kristaps 179: .It Fl T Ns Cm html
1.57 kristaps 180: Produce strict HTML-4.01 output, with a sane default style.
181: See
1.48 kristaps 182: .Sx HTML Output .
1.37 kristaps 183: .
1.58 ! kristaps 184: .It Fl T Ns Cm lint
! 185: Parse only: produce no output.
! 186: Implies
! 187: .Fl W Ns Cm all
! 188: and
! 189: .Fl f Ns Cm strict .
! 190: .
! 191: .It Fl T Ns Cm tree
! 192: Produce an indented parse tree.
! 193: .
! 194: .It Fl T Ns Cm xhtml
1.57 kristaps 195: Produce strict XHTML-1.0 output, with a sane default style.
196: See
1.50 kristaps 197: .Sx XHTML Output .
1.1 kristaps 198: .El
1.32 kristaps 199: .
1.13 kristaps 200: .Pp
201: If multiple input files are specified, these will be processed by the
202: corresponding filter in-order.
1.32 kristaps 203: .
204: .
1.1 kristaps 205: .Ss Compiler Options
1.35 kristaps 206: Default compiler behaviour may be overridden with the
1.1 kristaps 207: .Fl f
208: flag.
1.32 kristaps 209: .
1.19 kristaps 210: .Bl -tag -width Ds
1.58 ! kristaps 211: .It Fl f Ns Cm ign-errors
! 212: When parsing multiple files, don't halt when one errors out.
! 213: Useful with
! 214: .Fl T Ns Cm lint
! 215: over a large set of manuals passed on the command line.
! 216: .
! 217: .It Fl f Ns Cm ign-escape
! 218: Ignore invalid escape sequences.
! 219: This is the default, but the option can be used to override an earlier
! 220: .Fl f Ns Cm strict .
! 221: .
! 222: .It Fl f Ns Cm ign-scope
1.1 kristaps 223: When rewinding the scope of a block macro, forces the compiler to ignore
1.57 kristaps 224: scope violations.
225: This can seriously mangle the resulting tree.
1.8 kristaps 226: .Pq mdoc only
1.32 kristaps 227: .
1.58 ! kristaps 228: .It Fl f Ns Cm no-ign-chars
! 229: Do not ignore disallowed characters.
1.45 kristaps 230: .
1.58 ! kristaps 231: .It Fl f Ns Cm no-ign-escape
! 232: Do not ignore invalid escape sequences.
1.32 kristaps 233: .
1.58 ! kristaps 234: .It Fl f Ns Cm no-ign-macro
1.21 kristaps 235: Do not ignore unknown macros at the start of input lines.
1.32 kristaps 236: .
1.58 ! kristaps 237: .It Fl f Ns Cm strict
1.26 kristaps 238: Implies
1.58 ! kristaps 239: .Fl f Ns Cm no-ign-escape ,
! 240: .Fl f Ns Cm no-ign-macro ,
1.21 kristaps 241: and
1.58 ! kristaps 242: .Fl f Ns Cm no-ign-chars .
1.1 kristaps 243: .El
1.32 kristaps 244: .
1.48 kristaps 245: .
1.37 kristaps 246: .Ss Output Options
247: For the time being, only
248: .Fl T Ns Ar html
1.52 kristaps 249: and
250: .Fl T Ns Ar xhtml
1.58 ! kristaps 251: accept output options:
1.37 kristaps 252: .Bl -tag -width Ds
1.58 ! kristaps 253: .It Fl O Ns Cm includes Ns = Ns Ar fmt
1.40 kristaps 254: The string
255: .Ar fmt ,
1.49 kristaps 256: for example,
1.40 kristaps 257: .Ar ../src/%I.html ,
258: is used as a template for linked header files (usually via the
259: .Sq \&In
1.57 kristaps 260: macro).
261: Instances of
1.43 kristaps 262: .Sq \&%I
1.57 kristaps 263: are replaced with the include filename.
264: The default is not to present a
1.40 kristaps 265: hyperlink.
1.58 ! kristaps 266: .It Fl O Ns Cm man Ns = Ns Ar fmt
1.39 kristaps 267: The string
268: .Ar fmt ,
1.49 kristaps 269: for example,
1.39 kristaps 270: .Ar ../html%S/%N.%S.html ,
271: is used as a template for linked manuals (usually via the
1.37 kristaps 272: .Sq \&Xr
1.57 kristaps 273: macro).
274: Instances of
1.43 kristaps 275: .Sq \&%N
1.40 kristaps 276: and
277: .Sq %S
278: are replaced with the linked manual's name and section, respectively.
1.57 kristaps 279: If no section is included, section 1 is assumed.
280: The default is not to
1.40 kristaps 281: present a hyperlink.
1.58 ! kristaps 282: .It Fl O Ns Cm style Ns = Ns Ar style.css
! 283: The file
! 284: .Ar style.css
! 285: is used for an external style-sheet.
! 286: This must be a valid absolute or
! 287: relative URI.
1.37 kristaps 288: .El
1.32 kristaps 289: .
1.48 kristaps 290: .
291: .Sh OUTPUT
292: This section documents output details of
293: .Nm .
294: In general, output conforms to the traditional manual style of a header,
1.49 kristaps 295: a body composed of sections and sub-sections, and a footer.
1.48 kristaps 296: .Pp
297: The text style of output characters (non-macro characters, punctuation,
298: and white-space) is dictated by context.
299: .Pp
1.57 kristaps 300: White-space is generally stripped from input.
301: This can be changed with
1.48 kristaps 302: character escapes (specified in
303: .Xr mandoc_char 7 )
304: or literal modes (specified in
305: .Xr mdoc 7
306: and
307: .Xr man 7 ) .
308: .Pp
309: If non-macro punctuation is set apart from words, such as in the phrase
310: .Dq to be \&, or not to be ,
311: it's processed by
312: .Nm ,
313: regardless of output format, according to the following rules: opening
314: punctuation
315: .Po
316: .Sq \&( ,
317: .Sq \&[ ,
318: and
319: .Sq \&{
320: .Pc
321: is not followed by a space; closing punctuation
322: .Po
323: .Sq \&. ,
324: .Sq \&, ,
325: .Sq \&; ,
326: .Sq \&: ,
327: .Sq \&? ,
328: .Sq \&! ,
329: .Sq \&) ,
330: .Sq \&]
331: and
332: .Sq \&}
333: .Pc
334: is not preceded by white-space.
335: .
336: .Pp
337: If the input is
338: .Xr mdoc 7 ,
339: however, these rules are also applied to macro arguments when appropriate.
340: .
341: .
342: .Ss ASCII Output
1.49 kristaps 343: Output produced by
1.58 ! kristaps 344: .Fl T Ns Cm ascii ,
1.48 kristaps 345: which is the default, is rendered in standard 7-bit ASCII documented in
346: .Xr ascii 7 .
347: .Pp
348: Font styles are applied by using back-spaced encoding such that an
349: underlined character
350: .Sq c
351: is rendered as
352: .Sq _ Ns \e[bs] Ns c ,
353: where
354: .Sq \e[bs]
1.57 kristaps 355: is the back-space character number 8.
356: Emboldened characters are rendered as
1.48 kristaps 357: .Sq c Ns \e[bs] Ns c .
358: .Pp
359: The special characters documented in
360: .Xr mandoc_char 7
361: are rendered best-effort in an ASCII equivalent.
362: .Pp
363: Output width is limited to 78 visible columns unless literal input lines
364: exceed this limit.
365: .
366: .
367: .Ss HTML Output
368: Output produced by
1.58 ! kristaps 369: .Fl T Ns Cm html
1.50 kristaps 370: conforms to HTML-4.01 strict.
1.48 kristaps 371: .Pp
1.57 kristaps 372: Font styles and page structure are applied using CSS2.
373: By default, no font style is applied to any text,
374: although CSS2 is hard-coded to format
1.48 kristaps 375: the basic structure of output.
376: .Pp
377: The
378: .Pa example.style.css
379: file documents the range of styles applied to output and, if used, will
380: cause rendered documents to appear as they do in
1.58 ! kristaps 381: .Fl T Ns Cm ascii .
1.48 kristaps 382: .Pp
383: Special characters are rendered in decimal-encoded UTF-8.
384: .
385: .
1.50 kristaps 386: .Ss XHTML Output
387: Output produced by
1.58 ! kristaps 388: .Fl T Ns Cm xhtml
1.50 kristaps 389: conforms to XHTML-1.0 strict.
390: .Pp
391: See
392: .Sx HTML Output
393: for details; beyond generating XHTML tags instead of HTML tags, these
394: output modes are identical.
395: .
396: .
1.1 kristaps 397: .Sh EXAMPLES
1.13 kristaps 398: To page manuals to the terminal:
1.32 kristaps 399: .
1.1 kristaps 400: .Pp
1.58 ! kristaps 401: .D1 $ mandoc \-Wall,error \-fstrict mandoc.1 2\*(Gt&1 | less
! 402: .D1 $ mandoc mandoc.1 mdoc.3 mdoc.7 | less
1.32 kristaps 403: .
1.28 kristaps 404: .Pp
1.41 kristaps 405: To produce HTML manuals with
406: .Ar style.css
407: as the style-sheet:
1.38 kristaps 408: .Pp
1.58 ! kristaps 409: .D1 $ mandoc \-Thtml -Ostyle=style.css mdoc.7 \*(Gt mdoc.7.html
1.38 kristaps 410: .Pp
1.28 kristaps 411: To check over a large set of manuals:
1.32 kristaps 412: .
1.28 kristaps 413: .Pp
1.58 ! kristaps 414: .Dl $ mandoc \-Tlint \-fign-errors `find /usr/src -name \e*\e.[1-9]`
1.32 kristaps 415: .
416: .
1.20 kristaps 417: .Sh COMPATIBILITY
1.26 kristaps 418: This section summarises
1.20 kristaps 419: .Nm
1.26 kristaps 420: compatibility with
1.20 kristaps 421: .Xr groff 1 .
1.32 kristaps 422: Each input and output format is separately noted.
423: .
424: .
1.48 kristaps 425: .Ss ASCII Compatibility
1.37 kristaps 426: .Bl -bullet -compact
1.29 kristaps 427: .It
1.49 kristaps 428: The
1.29 kristaps 429: .Sq \e~
1.49 kristaps 430: special character doesn't produce expected behaviour in
1.58 ! kristaps 431: .Fl T Ns Cm ascii .
1.32 kristaps 432: .
433: .It
1.49 kristaps 434: The
1.33 kristaps 435: .Sq \&Bd \-literal
1.49 kristaps 436: and
1.32 kristaps 437: .Sq \&Bd \-unfilled
438: macros of
439: .Xr mdoc 7
440: in
1.58 ! kristaps 441: .Fl T Ns Cm ascii
1.32 kristaps 442: are synonyms, as are \-filled and \-ragged.
443: .
1.26 kristaps 444: .It
1.49 kristaps 445: In
1.27 kristaps 446: .Xr groff 1 ,
447: the
448: .Sq \&Pa
1.32 kristaps 449: .Xr mdoc 7
450: macro does not underline when scoped under an
1.30 kristaps 451: .Sq \&It
1.57 kristaps 452: in the FILES section.
453: This behaves correctly in
1.27 kristaps 454: .Nm .
1.32 kristaps 455: .
1.27 kristaps 456: .It
1.58 ! kristaps 457: A list or display following the
1.27 kristaps 458: .Sq \&Ss
1.32 kristaps 459: .Xr mdoc 7
460: macro in
1.58 ! kristaps 461: .Fl T Ns Cm ascii
1.20 kristaps 462: does not assert a prior vertical break, just as it doesn't with
1.27 kristaps 463: .Sq \&Sh .
1.32 kristaps 464: .
1.20 kristaps 465: .It
1.32 kristaps 466: The
467: .Sq \&na
468: .Xr man 7
1.34 kristaps 469: macro in
1.58 ! kristaps 470: .Fl T Ns Cm ascii
1.34 kristaps 471: has no effect.
1.32 kristaps 472: .
1.20 kristaps 473: .It
474: Words aren't hyphenated.
1.32 kristaps 475: .
1.22 kristaps 476: .It
477: In normal mode (not a literal block), blocks of spaces aren't preserved,
1.32 kristaps 478: so double spaces following sentence closure are reduced to a single space;
479: .Xr groff 1
480: retains spaces.
481: .
482: .It
483: Sentences are unilaterally monospaced.
1.20 kristaps 484: .El
1.42 kristaps 485: .
1.48 kristaps 486: .
1.50 kristaps 487: .Ss HTML/XHTML Compatibility
1.42 kristaps 488: .Bl -bullet -compact
489: .It
490: The
1.47 kristaps 491: .Sq \efP
492: escape will revert the font to the previous
493: .Sq \ef
494: escape, not to the last rendered decoration, which is now dictated by
1.57 kristaps 495: CSS instead of hard-coded.
496: It also will not span past the current scope,
497: for the same reason.
498: Note that in
1.47 kristaps 499: .Sx ASCII Output
500: mode, this will work fine.
501: .It
502: The
1.42 kristaps 503: .Xr mdoc 7
504: .Sq \&Bl \-hang
505: and
506: .Sq \&Bl \-tag
507: list types render similarly (no break following overreached left-hand
508: side) due to the expressive constraints of HTML.
509: .
510: .It
511: The
512: .Xr man 7
513: .Sq IP
514: and
515: .Sq TP
516: lists render similarly.
517: .El
1.48 kristaps 518: .
519: .
1.1 kristaps 520: .Sh SEE ALSO
1.57 kristaps 521: .Xr man 7 ,
1.13 kristaps 522: .Xr mandoc_char 7 ,
1.57 kristaps 523: .Xr mdoc 7
1.39 kristaps 524: .
1.1 kristaps 525: .Sh AUTHORS
526: The
527: .Nm
1.26 kristaps 528: utility was written by
1.18 kristaps 529: .An Kristaps Dzonsons Aq kristaps@kth.se .
1.39 kristaps 530: .
1.48 kristaps 531: .
1.39 kristaps 532: .Sh CAVEATS
1.48 kristaps 533: The
1.58 ! kristaps 534: .Fl T Ns Cm html
1.50 kristaps 535: and
1.58 ! kristaps 536: .Fl T Ns Cm xhtml
1.48 kristaps 537: CSS2 styling used for
1.58 ! kristaps 538: .Fl m Ns Cm doc
1.51 kristaps 539: input lists does not render properly in older browsers, such as Internet
540: Explorer 6 and earlier.
1.54 kristaps 541: .
1.48 kristaps 542: .Pp
1.39 kristaps 543: In
1.58 ! kristaps 544: .Fl T Ns Cm html
1.50 kristaps 545: and
1.58 ! kristaps 546: .Fl T Ns Cm xhtml ,
1.39 kristaps 547: the maximum size of an element attribute is determined by
548: .Dv BUFSIZ ,
1.57 kristaps 549: which is usually 1024 bytes.
550: Be aware of this when setting long link
1.58 ! kristaps 551: formats such as
! 552: .Fl O Ns Cm style Ns = Ns Ar really/long/link .
1.54 kristaps 553: .
1.46 kristaps 554: .Pp
555: The
1.58 ! kristaps 556: .Fl T Ns Cm html
1.50 kristaps 557: and
1.58 ! kristaps 558: .Fl T Ns Cm xhtml
1.50 kristaps 559: output modes don't render the
1.46 kristaps 560: .Sq \es
1.47 kristaps 561: font size escape documented in
1.46 kristaps 562: .Xr mdoc 7
563: and
564: .Xr man 7 .
1.54 kristaps 565: .
1.51 kristaps 566: .Pp
567: Nesting elements within next-line element scopes of
1.58 ! kristaps 568: .Fl m Ns Cm an ,
1.51 kristaps 569: such as
570: .Sq br
571: within an empty
572: .Sq B ,
573: will confuse
1.58 ! kristaps 574: .Fl T Ns Cm html
1.51 kristaps 575: and
1.58 ! kristaps 576: .Fl T Ns Cm xhtml
1.52 kristaps 577: and cause them to forget the formatting of the prior next-line scope.
1.54 kristaps 578: .
1.53 kristaps 579: .Pp
580: The
581: .Sq i
582: macro in
1.58 ! kristaps 583: .Fl m Ns Cm an
1.53 kristaps 584: should italicise all subsequent text if a line argument is not provided.
585: This behaviour is not implemented.
1.54 kristaps 586: .
587: The
588: .Sq \(aq
1.55 kristaps 589: control character is an alias for the standard macro control character
590: and does not emit a line-break as stipulated in GNU troff.
CVSweb