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