]> git.cameronkatri.com Git - mandoc.git/blob - mandoc.1
First, I'm defaulting to 11-point font, which renders much nicer (the
[mandoc.git] / mandoc.1
1 .\" $Id: mandoc.1,v 1.68 2010/07/01 14:23:45 kristaps Exp $
2 .\"
3 .\" Copyright (c) 2009 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: July 1 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 ps
196 Produce PostScript output.
197 See
198 .Sx PostScript Output .
199 .It Fl T Ns Cm tree
200 Produce an indented parse tree.
201 .It Fl T Ns Cm xhtml
202 Produce strict XHTML-1.0 output, with a sane default style.
203 See
204 .Sx XHTML Output .
205 .El
206 .Pp
207 If multiple input files are specified, these will be processed by the
208 corresponding filter in-order.
209 .Ss ASCII Output
210 Output produced by
211 .Fl T Ns Cm ascii ,
212 which is the default, is rendered in standard 7-bit ASCII documented in
213 .Xr ascii 7 .
214 .Pp
215 Font styles are applied by using back-spaced encoding such that an
216 underlined character
217 .Sq c
218 is rendered as
219 .Sq _ Ns \e[bs] Ns c ,
220 where
221 .Sq \e[bs]
222 is the back-space character number 8.
223 Emboldened characters are rendered as
224 .Sq c Ns \e[bs] Ns c .
225 .Pp
226 The special characters documented in
227 .Xr mandoc_char 7
228 are rendered best-effort in an ASCII equivalent.
229 .Pp
230 Output width is limited to 78 visible columns unless literal input lines
231 exceed this limit.
232 .Pp
233 The following
234 .Fl O
235 arguments are accepted:
236 .Bl -tag -width Ds
237 .It Cm width Ns = Ns Ar width
238 The output width is set to
239 .Ar width ,
240 which will normalise to \(>=60.
241 .El
242 .Ss HTML Output
243 Output produced by
244 .Fl T Ns Cm html
245 conforms to HTML-4.01 strict.
246 .Pp
247 Font styles and page structure are applied using CSS2.
248 By default, no font style is applied to any text,
249 although CSS2 is hard-coded to format
250 the basic structure of output.
251 .Pp
252 The
253 .Pa example.style.css
254 file documents the range of styles applied to output and, if used, will
255 cause rendered documents to appear as they do in
256 .Fl T Ns Cm ascii .
257 .Pp
258 Special characters are rendered in decimal-encoded UTF-8.
259 .Pp
260 The following
261 .Fl O
262 arguments are accepted:
263 .Bl -tag -width Ds
264 .It Cm includes Ns = Ns Ar fmt
265 The string
266 .Ar fmt ,
267 for example,
268 .Ar ../src/%I.html ,
269 is used as a template for linked header files (usually via the
270 .Sq \&In
271 macro).
272 Instances of
273 .Sq \&%I
274 are replaced with the include filename.
275 The default is not to present a
276 hyperlink.
277 .It Cm man Ns = Ns Ar fmt
278 The string
279 .Ar fmt ,
280 for example,
281 .Ar ../html%S/%N.%S.html ,
282 is used as a template for linked manuals (usually via the
283 .Sq \&Xr
284 macro).
285 Instances of
286 .Sq \&%N
287 and
288 .Sq %S
289 are replaced with the linked manual's name and section, respectively.
290 If no section is included, section 1 is assumed.
291 The default is not to
292 present a hyperlink.
293 .It Cm style Ns = Ns Ar style.css
294 The file
295 .Ar style.css
296 is used for an external style-sheet.
297 This must be a valid absolute or
298 relative URI.
299 .El
300 .Ss PostScript Output
301 PostScript
302 .Qq Adobe-3.0
303 Level-2 pages may be generated by
304 .Fl T Ns Cm ps .
305 Output pages default to letter sized and are rendered in the Times font
306 family, 11-point.
307 .Pp
308 Special characters are rendered as in
309 .Sx ASCII Output .
310 .Pp
311 The following
312 .Fl O
313 arguments are accepted:
314 .Bl -tag -width Ds
315 .It Cm paper Ns = Ns Ar name
316 The paper size
317 .Ar name
318 may be one of
319 .Ar a3 ,
320 .Ar a4 ,
321 .Ar a5 ,
322 .Ar legal ,
323 or
324 .Ar letter .
325 You may also manually specify dimensions as
326 .Ar NNxNN ,
327 width by height in millimetres.
328 If an unknown value is encountered,
329 .Ar letter
330 is used.
331 .El
332 .Ss XHTML Output
333 Output produced by
334 .Fl T Ns Cm xhtml
335 conforms to XHTML-1.0 strict.
336 .Pp
337 See
338 .Sx HTML Output
339 for details; beyond generating XHTML tags instead of HTML tags, these
340 output modes are identical.
341 .Sh EXAMPLES
342 To page manuals to the terminal:
343 .Pp
344 .D1 $ mandoc \-Wall,error \-fstrict mandoc.1 2\*(Gt&1 | less
345 .D1 $ mandoc mandoc.1 mdoc.3 mdoc.7 | less
346 .Pp
347 To produce HTML manuals with
348 .Ar style.css
349 as the style-sheet:
350 .Pp
351 .D1 $ mandoc \-Thtml -Ostyle=style.css mdoc.7 \*(Gt mdoc.7.html
352 .Pp
353 To check over a large set of manuals:
354 .Pp
355 .Dl $ mandoc \-Tlint \-fign-errors `find /usr/src -name \e*\e.[1-9]`
356 .Pp
357 To produce a series of PostScript manuals for A4 paper:
358 .Pp
359 .D1 $ mandoc \-Tps \-Opaper=a4 mdoc.7 man.7 \*(Gt manuals.ps
360 .Sh COMPATIBILITY
361 This section summarises
362 .Nm
363 compatibility with
364 .Xr groff 1 .
365 Each input and output format is separately noted.
366 .Ss ASCII Compatibility
367 .Bl -bullet -compact
368 .It
369 The
370 .Sq \e~
371 special character doesn't produce expected behaviour in
372 .Fl T Ns Cm ascii .
373 .It
374 The
375 .Sq \&Bd \-literal
376 and
377 .Sq \&Bd \-unfilled
378 macros of
379 .Xr mdoc 7
380 in
381 .Fl T Ns Cm ascii
382 are synonyms, as are \-filled and \-ragged.
383 .It
384 In
385 .Xr groff 1 ,
386 the
387 .Sq \&Pa
388 .Xr mdoc 7
389 macro does not underline when scoped under an
390 .Sq \&It
391 in the FILES section.
392 This behaves correctly in
393 .Nm .
394 .It
395 A list or display following the
396 .Sq \&Ss
397 .Xr mdoc 7
398 macro in
399 .Fl T Ns Cm ascii
400 does not assert a prior vertical break, just as it doesn't with
401 .Sq \&Sh .
402 .It
403 The
404 .Sq \&na
405 .Xr man 7
406 macro in
407 .Fl T Ns Cm ascii
408 has no effect.
409 .It
410 Words aren't hyphenated.
411 .It
412 In normal mode (not a literal block), blocks of spaces aren't preserved,
413 so double spaces following sentence closure are reduced to a single space;
414 .Xr groff 1
415 retains spaces.
416 .It
417 Sentences are unilaterally monospaced.
418 .El
419 .Ss HTML/XHTML Compatibility
420 .Bl -bullet -compact
421 .It
422 The
423 .Sq \efP
424 escape will revert the font to the previous
425 .Sq \ef
426 escape, not to the last rendered decoration, which is now dictated by
427 CSS instead of hard-coded.
428 It also will not span past the current scope,
429 for the same reason.
430 Note that in
431 .Sx ASCII Output
432 mode, this will work fine.
433 .It
434 The
435 .Xr mdoc 7
436 .Sq \&Bl \-hang
437 and
438 .Sq \&Bl \-tag
439 list types render similarly (no break following overreached left-hand
440 side) due to the expressive constraints of HTML.
441 .It
442 The
443 .Xr man 7
444 .Sq IP
445 and
446 .Sq TP
447 lists render similarly.
448 .El
449 .Sh SEE ALSO
450 .Xr man 7 ,
451 .Xr mandoc_char 7 ,
452 .Xr mdoc 7
453 .Sh AUTHORS
454 The
455 .Nm
456 utility was written by
457 .An Kristaps Dzonsons Aq kristaps@bsd.lv .
458 .Sh CAVEATS
459 The
460 .Fl T Ns Cm html
461 and
462 .Fl T Ns Cm xhtml
463 CSS2 styling used for
464 .Fl m Ns Cm doc
465 input lists does not render properly in older browsers, such as Internet
466 Explorer 6 and earlier.
467 .Pp
468 In
469 .Fl T Ns Cm html
470 and
471 .Fl T Ns Cm xhtml ,
472 the maximum size of an element attribute is determined by
473 .Dv BUFSIZ ,
474 which is usually 1024 bytes.
475 Be aware of this when setting long link
476 formats such as
477 .Fl O Ns Cm style Ns = Ns Ar really/long/link .
478 .Pp
479 The
480 .Fl T Ns Cm html
481 and
482 .Fl T Ns Cm xhtml
483 output modes don't render the
484 .Sq \es
485 font size escape documented in
486 .Xr mdoc 7
487 and
488 .Xr man 7 .
489 .Pp
490 Nesting elements within next-line element scopes of
491 .Fl m Ns Cm an ,
492 such as
493 .Sq br
494 within an empty
495 .Sq B ,
496 will confuse
497 .Fl T Ns Cm html
498 and
499 .Fl T Ns Cm xhtml
500 and cause them to forget the formatting of the prior next-line scope.
501 .Pp
502 The
503 .Sq i
504 macro in
505 .Fl m Ns Cm an
506 should italicise all subsequent text if a line argument is not provided.
507 This behaviour is not implemented.
508 The
509 .Sq \(aq
510 control character is an alias for the standard macro control character
511 and does not emit a line-break as stipulated in GNU troff.