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