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