Annotation of src/usr.bin/mandoc/mandoc.1, Revision 1.38
1.38 ! schwarze 1: .\" $OpenBSD: mandoc.1,v 1.37 2010/08/18 01:35:01 schwarze Exp $
1.1 kristaps 2: .\"
1.35 schwarze 3: .\" Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
1.1 kristaps 4: .\"
5: .\" Permission to use, copy, modify, and distribute this software for any
1.3 schwarze 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.3 schwarze 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.38 ! schwarze 17: .Dd $Mdocdate: August 18 2010 $
1.2 deraadt 18: .Dt MANDOC 1
1.1 kristaps 19: .Os
20: .Sh NAME
21: .Nm mandoc
22: .Nd format and display UNIX manuals
23: .Sh SYNOPSIS
24: .Nm mandoc
1.26 jmc 25: .Op Fl V
1.1 kristaps 26: .Op Fl m Ns Ar format
1.26 jmc 27: .Op Fl O Ns Ar option
1.17 schwarze 28: .Op Fl T Ns Ar output
1.38 ! schwarze 29: .Op Fl W Ns Ar level
1.26 jmc 30: .Op Ar file...
1.1 kristaps 31: .Sh DESCRIPTION
32: The
33: .Nm
1.10 schwarze 34: utility formats
1.1 kristaps 35: .Ux
1.25 jmc 36: manual pages for display.
37: The arguments are as follows:
1.5 schwarze 38: .Bl -tag -width Ds
1.1 kristaps 39: .It Fl m Ns Ar format
1.25 jmc 40: Input format.
41: See
1.1 kristaps 42: .Sx Input Formats
1.25 jmc 43: for available formats.
44: Defaults to
1.26 jmc 45: .Fl m Ns Cm andoc .
46: .It Fl O Ns Ar option
1.25 jmc 47: Comma-separated output options.
1.1 kristaps 48: .It Fl T Ns Ar output
1.25 jmc 49: Output format.
50: See
1.1 kristaps 51: .Sx Output Formats
1.25 jmc 52: for available formats.
53: Defaults to
1.26 jmc 54: .Fl T Ns Cm ascii .
1.4 schwarze 55: .It Fl V
56: Print version and exit.
1.38 ! schwarze 57: .It Fl W Ns Ar level
! 58: Specify the minimum message
! 59: .Ar level
! 60: to be reported on the standard error output and to affect the exit status.
! 61: The
! 62: .Ar level
! 63: can be
! 64: .Cm warning ,
! 65: .Cm error ,
! 66: or
! 67: .Cm fatal .
! 68: The default is
! 69: .Fl W Ns Cm fatal ;
1.26 jmc 70: .Fl W Ns Cm all
1.38 ! schwarze 71: is an alias for
! 72: .Fl W Ns Cm warning .
! 73: See
! 74: .Sx EXIT STATUS
! 75: and
! 76: .Sx DIAGNOSTICS
! 77: for details.
! 78: .Pp
! 79: The special option
! 80: .Fl W Ns Cm stop
! 81: tells
! 82: .Nm
! 83: to exit after parsing a file that causes warnings or errors of at least
! 84: the requested level.
! 85: No formatted output will be produced from that file.
! 86: If both a
! 87: .Ar level
! 88: and
! 89: .Cm stop
! 90: are requested, they can be joined with a comma, for example
! 91: .Fl W Ns Cm error , Ns Cm stop .
1.26 jmc 92: .It Ar file
93: Read input from zero or more files.
1.25 jmc 94: If unspecified, reads from stdin.
95: If multiple files are specified,
1.1 kristaps 96: .Nm
97: will halt with the first failed parse.
98: .El
99: .Pp
1.10 schwarze 100: By default,
101: .Nm
102: reads
1.1 kristaps 103: .Xr mdoc 7
104: or
105: .Xr man 7
106: text from stdin, implying
1.26 jmc 107: .Fl m Ns Cm andoc ,
1.20 schwarze 108: and produces
1.26 jmc 109: .Fl T Ns Cm ascii
1.20 schwarze 110: output.
1.1 kristaps 111: .Ss Input Formats
112: The
113: .Nm
114: utility accepts
115: .Xr mdoc 7
116: and
117: .Xr man 7
118: input with
1.26 jmc 119: .Fl m Ns Cm doc
1.1 kristaps 120: and
1.26 jmc 121: .Fl m Ns Cm an ,
1.25 jmc 122: respectively.
123: The
1.1 kristaps 124: .Xr mdoc 7
125: format is
126: .Em strongly
1.10 schwarze 127: recommended;
1.1 kristaps 128: .Xr man 7
129: should only be used for legacy manuals.
130: .Pp
131: A third option,
1.26 jmc 132: .Fl m Ns Cm andoc ,
1.1 kristaps 133: which is also the default, determines encoding on-the-fly: if the first
1.10 schwarze 134: non-comment macro is
1.11 schwarze 135: .Sq \&Dd
1.1 kristaps 136: or
1.11 schwarze 137: .Sq \&Dt ,
1.10 schwarze 138: the
1.1 kristaps 139: .Xr mdoc 7
140: parser is used; otherwise, the
141: .Xr man 7
142: parser is used.
143: .Pp
144: If multiple
1.10 schwarze 145: files are specified with
1.26 jmc 146: .Fl m Ns Cm andoc ,
1.25 jmc 147: each has its file-type determined this way.
148: If multiple files are
1.1 kristaps 149: specified and
1.26 jmc 150: .Fl m Ns Cm doc
1.1 kristaps 151: or
1.26 jmc 152: .Fl m Ns Cm an
1.1 kristaps 153: is specified, then this format is used exclusively.
154: .Ss Output Formats
155: The
156: .Nm
157: utility accepts the following
158: .Fl T
1.34 schwarze 159: arguments, which correspond to output modes:
1.5 schwarze 160: .Bl -tag -width Ds
1.26 jmc 161: .It Fl T Ns Cm ascii
1.1 kristaps 162: Produce 7-bit ASCII output, backspace-encoded for bold and underline
1.25 jmc 163: styles.
164: This is the default.
165: See
1.20 schwarze 166: .Sx ASCII Output .
1.26 jmc 167: .It Fl T Ns Cm html
1.25 jmc 168: Produce strict HTML-4.01 output, with a sane default style.
169: See
1.20 schwarze 170: .Sx HTML Output .
1.26 jmc 171: .It Fl T Ns Cm lint
172: Parse only: produce no output.
173: Implies
1.38 ! schwarze 174: .Fl W Ns Cm warning .
1.36 schwarze 175: .It Fl T Ns Cm pdf
176: Produce PDF output.
177: See
178: .Sx PDF Output .
1.31 schwarze 179: .It Fl T Ns Cm ps
180: Produce PostScript output.
181: See
182: .Sx PostScript Output .
1.26 jmc 183: .It Fl T Ns Cm tree
184: Produce an indented parse tree.
185: .It Fl T Ns Cm xhtml
1.25 jmc 186: Produce strict XHTML-1.0 output, with a sane default style.
187: See
1.21 schwarze 188: .Sx XHTML Output .
1.1 kristaps 189: .El
190: .Pp
191: If multiple input files are specified, these will be processed by the
192: corresponding filter in-order.
1.34 schwarze 193: .Ss ASCII Output
194: Output produced by
195: .Fl T Ns Cm ascii ,
196: which is the default, is rendered in standard 7-bit ASCII documented in
197: .Xr ascii 7 .
198: .Pp
199: Font styles are applied by using back-spaced encoding such that an
200: underlined character
201: .Sq c
202: is rendered as
203: .Sq _ Ns \e[bs] Ns c ,
204: where
205: .Sq \e[bs]
206: is the back-space character number 8.
207: Emboldened characters are rendered as
208: .Sq c Ns \e[bs] Ns c .
209: .Pp
210: The special characters documented in
211: .Xr mandoc_char 7
212: are rendered best-effort in an ASCII equivalent.
213: .Pp
214: Output width is limited to 78 visible columns unless literal input lines
215: exceed this limit.
216: .Pp
217: The following
218: .Fl O
219: arguments are accepted:
1.5 schwarze 220: .Bl -tag -width Ds
1.34 schwarze 221: .It Cm width Ns = Ns Ar width
222: The output width is set to
223: .Ar width ,
224: which will normalise to \(>=60.
1.1 kristaps 225: .El
1.34 schwarze 226: .Ss HTML Output
227: Output produced by
228: .Fl T Ns Cm html
229: conforms to HTML-4.01 strict.
230: .Pp
231: Font styles and page structure are applied using CSS2.
232: By default, no font style is applied to any text,
233: although CSS2 is hard-coded to format
234: the basic structure of output.
235: .Pp
1.30 schwarze 236: The
1.34 schwarze 237: .Pa example.style.css
238: file documents the range of styles applied to output and, if used, will
239: cause rendered documents to appear as they do in
240: .Fl T Ns Cm ascii .
241: .Pp
242: Special characters are rendered in decimal-encoded UTF-8.
243: .Pp
244: The following
1.33 schwarze 245: .Fl O
1.34 schwarze 246: arguments are accepted:
1.17 schwarze 247: .Bl -tag -width Ds
1.33 schwarze 248: .It Cm includes Ns = Ns Ar fmt
1.17 schwarze 249: The string
250: .Ar fmt ,
1.21 schwarze 251: for example,
1.17 schwarze 252: .Ar ../src/%I.html ,
253: is used as a template for linked header files (usually via the
254: .Sq \&In
1.25 jmc 255: macro).
256: Instances of
1.17 schwarze 257: .Sq \&%I
1.25 jmc 258: are replaced with the include filename.
259: The default is not to present a
1.17 schwarze 260: hyperlink.
1.33 schwarze 261: .It Cm man Ns = Ns Ar fmt
1.17 schwarze 262: The string
263: .Ar fmt ,
1.21 schwarze 264: for example,
1.17 schwarze 265: .Ar ../html%S/%N.%S.html ,
266: is used as a template for linked manuals (usually via the
267: .Sq \&Xr
1.25 jmc 268: macro).
269: Instances of
1.17 schwarze 270: .Sq \&%N
271: and
272: .Sq %S
273: are replaced with the linked manual's name and section, respectively.
1.25 jmc 274: If no section is included, section 1 is assumed.
275: The default is not to
1.17 schwarze 276: present a hyperlink.
1.33 schwarze 277: .It Cm style Ns = Ns Ar style.css
1.26 jmc 278: The file
279: .Ar style.css
280: is used for an external style-sheet.
281: This must be a valid absolute or
282: relative URI.
1.30 schwarze 283: .El
1.31 schwarze 284: .Ss PostScript Output
1.33 schwarze 285: PostScript
286: .Qq Adobe-3.0
287: Level-2 pages may be generated by
1.31 schwarze 288: .Fl T Ns Cm ps .
1.35 schwarze 289: Output pages default to letter sized and are rendered in the Times font
290: family, 11-point.
291: Margins are calculated as 1/9 the page length and width.
292: Line-height is 1.4m.
1.34 schwarze 293: .Pp
294: Special characters are rendered as in
295: .Sx ASCII Output .
296: .Pp
297: The following
298: .Fl O
299: arguments are accepted:
300: .Bl -tag -width Ds
301: .It Cm paper Ns = Ns Ar name
302: The paper size
303: .Ar name
304: may be one of
1.35 schwarze 305: .Ar a3 ,
306: .Ar a4 ,
307: .Ar a5 ,
308: .Ar legal ,
1.34 schwarze 309: or
310: .Ar letter .
1.35 schwarze 311: You may also manually specify dimensions as
312: .Ar NNxNN ,
313: width by height in millimetres.
314: If an unknown value is encountered,
315: .Ar letter
316: is used.
1.34 schwarze 317: .El
1.36 schwarze 318: .Ss PDF Output
319: PDF-1.1 output may be generated by
320: .Fl T Ns Cm pdf .
321: See
322: .Sx PostScript Output
323: for
324: .Fl O
325: arguments and defaults.
1.21 schwarze 326: .Ss XHTML Output
327: Output produced by
1.26 jmc 328: .Fl T Ns Cm xhtml
1.21 schwarze 329: conforms to XHTML-1.0 strict.
330: .Pp
331: See
332: .Sx HTML Output
333: for details; beyond generating XHTML tags instead of HTML tags, these
334: output modes are identical.
1.38 ! schwarze 335: .Sh EXIT STATUS
! 336: The
! 337: .Nm
! 338: utility exits with one of the following values, controlled by the message
! 339: .Ar level
! 340: associated with the
! 341: .Fl W
! 342: option:
! 343: .Pp
! 344: .Bl -tag -width Ds -compact
! 345: .It 0
! 346: No warnings or errors occurred, or those that did were ignored because
! 347: they were lower than the requested
! 348: .Ar level .
! 349: .It 2
! 350: At least one warning occurred, but no error, and
! 351: .Fl W Ns Cm warning
! 352: was specified.
! 353: .It 3
! 354: At least one parsing error occurred, but no fatal error, and
! 355: .Fl W Ns Cm error
! 356: or
! 357: .Fl W Ns Cm warning
! 358: was specified.
! 359: .It 4
! 360: A fatal parsing error occurred.
! 361: .It 5
! 362: Invalid command line arguments were specified.
! 363: No input files have been read.
! 364: .It 6
! 365: An operating system error occurred, for example memory exhaustion or an
! 366: error accessing input files.
! 367: Such errors cause
! 368: .Nm
! 369: to exit at once, possibly in the middle of parsing or formatting a file.
! 370: .El
! 371: .Pp
! 372: Note that selecting
! 373: .Fl T Ns Cm lint
! 374: output mode implies
! 375: .Fl W Ns Cm warning .
1.1 kristaps 376: .Sh EXAMPLES
377: To page manuals to the terminal:
378: .Pp
1.38 ! schwarze 379: .D1 $ mandoc \-Wall,stop mandoc.1 2\*(Gt&1 | less
1.26 jmc 380: .D1 $ mandoc mandoc.1 mdoc.3 mdoc.7 | less
1.12 schwarze 381: .Pp
1.17 schwarze 382: To produce HTML manuals with
383: .Ar style.css
384: as the style-sheet:
385: .Pp
1.26 jmc 386: .D1 $ mandoc \-Thtml -Ostyle=style.css mdoc.7 \*(Gt mdoc.7.html
1.17 schwarze 387: .Pp
1.12 schwarze 388: To check over a large set of manuals:
389: .Pp
1.38 ! schwarze 390: .Dl $ mandoc \-Tlint `find /usr/src -name \e*\e.[1-9]`
1.34 schwarze 391: .Pp
392: To produce a series of PostScript manuals for A4 paper:
393: .Pp
394: .D1 $ mandoc \-Tps \-Opaper=a4 mdoc.7 man.7 \*(Gt manuals.ps
1.38 ! schwarze 395: .Sh DIAGNOSTICS
! 396: Standard error messages reporting parsing errors are prefixed by
! 397: .Pp
! 398: .Sm off
! 399: .D1 Ar file : line : column : \ level :
! 400: .Sm on
! 401: .Pp
! 402: where the fields have the following meanings:
! 403: .Bl -tag -width "column"
! 404: .It Ar file
! 405: The name of the input file causing the message.
! 406: .It Ar line
! 407: The line number in that input file.
! 408: Line numbering starts at 1.
! 409: .It Ar column
! 410: The column number in that input file.
! 411: Column numbering starts at 1.
! 412: If the issue is caused by a word, the column number usually
! 413: points to the first character of the word.
! 414: .It Ar level
! 415: The message level, printed in capital letters.
! 416: .El
! 417: .Pp
! 418: Message levels have the following meanings:
! 419: .Bl -tag -width "warning"
! 420: .It Cm fatal
! 421: The parser is unable to parse a given input file at all.
! 422: No formatted output is produced from that input file.
! 423: .It Cm error
! 424: An input file contains syntax that cannot be safely interpreted,
! 425: either because it is invalid or because
! 426: .Nm
! 427: does not implement it yet.
! 428: By discarding part of the input or inserting missing tokens,
! 429: the parser is able to continue, and the error does not prevent
! 430: generation of formatted output, but typically, preparing that
! 431: output involves information loss, broken document structure
! 432: or unintended formatting.
! 433: .It Cm warning
! 434: An input file uses obsolete, discouraged or non-portable syntax.
! 435: All the same, the meaning of the input is unambiguous and a correct
! 436: rendering can be produced.
! 437: Documents causing warnings may render poorly when using other
! 438: formatting tools instead of
! 439: .Nm .
! 440: .El
! 441: .Pp
! 442: Messages of the
! 443: .Cm warning
! 444: and
! 445: .Cm error
! 446: levels are hidden unless their level, or a lower level, is requested using a
! 447: .Fl W
! 448: option or
! 449: .Fl T Ns Cm lint
! 450: output mode.
! 451: .Pp
! 452: The
! 453: .Nm
! 454: utility may also print messages related to invalid command line arguments
! 455: or operating system errors, for example when memory is exhausted or
! 456: input files cannot be read. Such messages do not carry the prefix
! 457: described above.
1.6 schwarze 458: .Sh COMPATIBILITY
1.10 schwarze 459: This section summarises
1.6 schwarze 460: .Nm
1.10 schwarze 461: compatibility with
1.6 schwarze 462: .Xr groff 1 .
1.14 schwarze 463: Each input and output format is separately noted.
1.20 schwarze 464: .Ss ASCII Compatibility
1.6 schwarze 465: .Bl -bullet -compact
1.13 schwarze 466: .It
1.21 schwarze 467: The
1.14 schwarze 468: .Sq \&Bd \-literal
1.21 schwarze 469: and
1.14 schwarze 470: .Sq \&Bd \-unfilled
471: macros of
472: .Xr mdoc 7
473: in
1.26 jmc 474: .Fl T Ns Cm ascii
1.14 schwarze 475: are synonyms, as are \-filled and \-ragged.
476: .It
1.21 schwarze 477: In
1.14 schwarze 478: .Xr groff 1 ,
479: the
480: .Sq \&Pa
481: .Xr mdoc 7
482: macro does not underline when scoped under an
483: .Sq \&It
1.25 jmc 484: in the FILES section.
485: This behaves correctly in
1.14 schwarze 486: .Nm .
1.10 schwarze 487: .It
1.26 jmc 488: A list or display following the
1.11 schwarze 489: .Sq \&Ss
1.14 schwarze 490: .Xr mdoc 7
491: macro in
1.26 jmc 492: .Fl T Ns Cm ascii
1.6 schwarze 493: does not assert a prior vertical break, just as it doesn't with
1.11 schwarze 494: .Sq \&Sh .
1.6 schwarze 495: .It
1.14 schwarze 496: The
497: .Sq \&na
498: .Xr man 7
1.16 schwarze 499: macro in
1.26 jmc 500: .Fl T Ns Cm ascii
1.16 schwarze 501: has no effect.
1.6 schwarze 502: .It
503: Words aren't hyphenated.
1.14 schwarze 504: .It
505: Sentences are unilaterally monospaced.
1.6 schwarze 506: .El
1.21 schwarze 507: .Ss HTML/XHTML Compatibility
1.17 schwarze 508: .Bl -bullet -compact
509: .It
510: The
1.20 schwarze 511: .Sq \efP
512: escape will revert the font to the previous
513: .Sq \ef
514: escape, not to the last rendered decoration, which is now dictated by
1.25 jmc 515: CSS instead of hard-coded.
516: It also will not span past the current scope,
517: for the same reason.
518: Note that in
1.20 schwarze 519: .Sx ASCII Output
520: mode, this will work fine.
521: .It
522: The
1.17 schwarze 523: .Xr mdoc 7
524: .Sq \&Bl \-hang
525: and
526: .Sq \&Bl \-tag
527: list types render similarly (no break following overreached left-hand
528: side) due to the expressive constraints of HTML.
529: .It
530: The
531: .Xr man 7
532: .Sq IP
533: and
534: .Sq TP
535: lists render similarly.
536: .El
1.1 kristaps 537: .Sh SEE ALSO
1.25 jmc 538: .Xr man 7 ,
1.1 kristaps 539: .Xr mandoc_char 7 ,
1.25 jmc 540: .Xr mdoc 7
1.1 kristaps 541: .Sh AUTHORS
542: The
543: .Nm
1.10 schwarze 544: utility was written by
1.29 schwarze 545: .An Kristaps Dzonsons Aq kristaps@bsd.lv .
1.17 schwarze 546: .Sh CAVEATS
1.20 schwarze 547: The
1.26 jmc 548: .Fl T Ns Cm html
1.21 schwarze 549: and
1.26 jmc 550: .Fl T Ns Cm xhtml
1.20 schwarze 551: CSS2 styling used for
1.26 jmc 552: .Fl m Ns Cm doc
1.22 schwarze 553: input lists does not render properly in older browsers, such as Internet
554: Explorer 6 and earlier.
1.20 schwarze 555: .Pp
1.17 schwarze 556: In
1.26 jmc 557: .Fl T Ns Cm html
1.21 schwarze 558: and
1.26 jmc 559: .Fl T Ns Cm xhtml ,
1.17 schwarze 560: the maximum size of an element attribute is determined by
561: .Dv BUFSIZ ,
1.25 jmc 562: which is usually 1024 bytes.
563: Be aware of this when setting long link
1.26 jmc 564: formats such as
565: .Fl O Ns Cm style Ns = Ns Ar really/long/link .
1.20 schwarze 566: .Pp
567: The
1.26 jmc 568: .Fl T Ns Cm html
1.21 schwarze 569: and
1.26 jmc 570: .Fl T Ns Cm xhtml
1.21 schwarze 571: output modes don't render the
1.20 schwarze 572: .Sq \es
573: font size escape documented in
574: .Xr mdoc 7
575: and
576: .Xr man 7 .
1.22 schwarze 577: .Pp
578: Nesting elements within next-line element scopes of
1.26 jmc 579: .Fl m Ns Cm an ,
1.22 schwarze 580: such as
581: .Sq br
582: within an empty
583: .Sq B ,
584: will confuse
1.26 jmc 585: .Fl T Ns Cm html
1.22 schwarze 586: and
1.26 jmc 587: .Fl T Ns Cm xhtml
1.23 schwarze 588: and cause them to forget the formatting of the prior next-line scope.
589: .Pp
590: The
591: .Sq i
592: macro in
1.26 jmc 593: .Fl m Ns Cm an
1.23 schwarze 594: should italicise all subsequent text if a line argument is not provided.
595: This behaviour is not implemented.
1.24 schwarze 596: The
597: .Sq \(aq
598: control character is an alias for the standard macro control character
599: and does not emit a line-break as stipulated in GNU troff.