summaryrefslogtreecommitdiffstats
path: root/src/utils/grog/grog.1.man
blob: efcd728193cbc38509ebf4debf3725c07e378735 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
.TH grog @MAN1EXT@ "@MDATE@" "groff @VERSION@"
.SH Name
grog \- \(lqgroff guess\(rq\(eminfer the
.I groff
command a document requires
.
.
.\" ====================================================================
.\" Legal Terms
.\" ====================================================================
.\"
.\" Copyright (C) 1989-2021 Free Software Foundation, Inc.
.\"
.\" This file is part of grog, which is part of groff, a free software
.\" project.  You can redistribute it and/or modify it under the terms
.\" of the GNU General Public License version 2 (GPL2) as published by
.\" the Free Software Foundation.
.\"
.\" groff is distributed in the hope that it will be useful, but WITHOUT
.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE.
.\"
.\" The text for GPL2 is available in the internet at
.\" <http://www.gnu.org/licenses/gpl2.0.txt>.
.
.
.\" Save and disable compatibility mode (for, e.g., Solaris 10/11).
.do nr *groff_grog_1_man_C \n[.cp]
.cp 0
.
.\" Define fallback for groff 1.23's MR macro if the system lacks it.
.nr do-fallback 0
.if !\n(.f           .nr do-fallback 1 \" mandoc
.if  \n(.g .if !d MR .nr do-fallback 1 \" older groff
.if !\n(.g           .nr do-fallback 1 \" non-groff *roff
.if \n[do-fallback]  \{\
.  de MR
.    ie \\n(.$=1 \
.      I \%\\$1
.    el \
.      IR \%\\$1 (\\$2)\\$3
.  .
.\}
.rr do-fallback
.
.
.\" ====================================================================
.SH Synopsis
.\" ====================================================================
.
.SY grog
.RB [ \-\-run ]
.RB [ \-\-ligatures ]
.RI [ groff-option\~ .\|.\|.\&]
.RB [ \-\- ]
.RI [ file\~ .\|.\|.]
.YS
.
.
.SY grog
.B \-h
.
.SY grog
.B \-\-help
.YS
.
.
.SY grog
.B \-v
.
.SY grog
.B \-\-version
.YS
.
.
.\" ====================================================================
.SH Description
.\" ====================================================================
.
.I grog
reads its input
and guesses which
.MR groff @MAN1EXT@
options are needed to render it.
.
If no operands are given,
or if
.I file
is
.RB \[lq] \- \[rq],
.I grog
reads the standard input stream.
.
The corresponding
.I groff
command is normally written to the standard output stream.
.
With the option
.BR \-\-run ,
the inferred command is written to the standard error stream and then
executed.
.
.
.\" ====================================================================
.SH Options
.\" ====================================================================
.
.B \-h
and
.B \-\-help
display a usage message,
whereas
.B \-v
and
.B \-\-version
display version information;
all exit afterward.
.
.
.TP
.B \-\-ligatures
includes the arguments
.B \-P\-y \-PU
in the inferred
.I groff
command.
.
These are supported only by the
.B pdf
output device.
.
.
.TP
.B \-\-run
writes the inferred command to the standard error stream and then
executes it.
.
.
.P
All other specified short options
(that is,
arguments beginning with a minus sign
.RB \[lq] \- \[rq]
followed by a letter)
are interpreted as
.I groff
options or option clusters with or without an option argument.
.
Such options are included in the constructed
.I groff
command line.
.
.
.\" ====================================================================
.SH Details
.\" ====================================================================
.
.I grog
reads each
.I file
operand,
pattern-matching strings that are statistically likely to be
characteristic of
.MR roff @MAN7EXT@
documents.
.
It tries to guess which of the following
.I groff
options are required to correctly render the input:
.BR \-e ,
.BR \-g ,
.BR \-G ,
.BR \-j ,
.\" gideal is not implemented yet.
.\" .BR \-J ,
.BR \-p ,
.BR \-R ,
.\".BR \-s ,
.B \-t
(preprocessors);
and
.BR \-man ,
.BR \-mdoc ,
.BR \-mdoc\-old ,
.BR \-me ,
.BR \-mm ,
.BR \-mom ,
and
.B \-ms
(macro packages).
.
The inferred
.I groff
command including these options and any
.I file
parameters is written to the standard output stream.
.
.
.P
It is possible to specify arbitrary
.I groff
options on the command line.
.
These are included in the inferred command without change.
.
Choices of
.I groff
options include
.B \-C
to enable AT&T
.I troff
compatibility mode and
.B \-T
to select a non-default output device.
.
If the input is not encoded in US-ASCII,
ISO 8859-1,
or IBM code page 1047,
specification of a
.I groff
option to run the
.MR preconv @MAN1EXT@
preprocessor is advised;
see the
.BR \-D ,
.BR \-k ,
and
.B \-K
options of
.MR groff @MAN1EXT@ .
.
For UTF-8 input,
.B \-k
is a good choice.
.
.
.P
.I groff
may issue diagnostic messages when an inappropriate
.B \-m
option,
or multiple conflicting ones,
are specified.
.
Consequently,
it is best to specify no
.B \-m
options to
.I grog
unless it cannot correctly infer all of the
.B \-m
arguments a document requires.
.
A
.I roff
document can also be written without recourse to any macro package.
.
In such cases,
.I grog
will infer a
.I groff
command without an
.B \-m
option.
.
.
.\" ====================================================================
.SS Limitations
.\" ====================================================================
.
.I grog
presumes that the input does not change the escape,
control,
or no-break control characters.
.
.I grog
does not parse
.I roff
input line continuation or control structures
(brace escape sequences and the
.RB \[lq] if \[rq],
.RB \[lq] ie \[rq],
and
.RB \[lq] el \[rq]
requests)
nor
.IR groff 's
.RB \[lq] while \[rq].
.
Thus the input
.
.RS
.EX
\&.if \[rs]
t .NH 1
\&.if n .SH
Introduction
.EE
.RE
.
will conceal the use of the
.I ms
macros
.B NH
and
.B SH
from
.IR grog .
.
Such constructions are regarded by
.IR grog 's
implementors as insufficiently common to cause many inference problems.
.
Preprocessors can be even stricter when matching macro calls that
bracket the regions of an input file they replace.
.
.IR pic ,
for example,
requires
.BR PS ,
.BR PE ,
and
.B PF
calls to immediately follow the default control character at the
beginning of a line.
.
.
.P
Detection of the
.B \-s
option
(the
.MR @g@soelim @MAN1EXT@
preprocessor)
is tricky;
to correctly infer its necessity would require
.I grog
to recursively open all files given as arguments to the
.B .so
request under the same conditions that
.I @g@soelim
itself does so;
see its man page.
.
Recall that
.I @g@soelim
is necessary only if sourced files need to be preprocessed.
.
Therefore,
as a workaround,
you may want to run the input through
.I @g@soelim
manually,
piping it to
.IR grog ,
and compare the output to running
.I grog
on the input directly.
.
If the
.RI \[lq] @g@soelim \[rq]ed
input causes
.I grog
to infer additional preprocessor options,
then
.B \-s
is likely necessary.
.
.
.RS
.P
.EX
$ \c
.B printf \[dq].TS\[rs]nl.\[rs]nI\[aq]m a table.\[rs]n.TE\[rs]n\[dq] > \
3.roff
$ \c
.B printf \[dq].so 3.roff\[rs]n\[dq] > 2.roff
$ \c
.B printf \[dq].XP\[rs]n.so 2.roff\[rs]n\[dq] > 1.roff
$ \c
.B grog 1.roff
groff \-ms 1.roff
$ \c
.B @g@soelim 1.roff | grog
groff \-t \-ms \-
.EE
.RE
.
.
.P
In the foregoing example,
we see that this procedure enabled
.I grog
to detect
.MR @g@tbl @MAN1EXT@
macros,
so we would add
.B \-s
as well as the detected
.B \-t
option to a revised
.I grog
or
.I groff
command.
.
.
.RS
.P
.EX
$ \c
.B grog \-st 1.roff
groff \-st \-ms 1.roff
.EE
.RE
.
.
.\" ====================================================================
.SH "Exit status"
.\" ====================================================================
.
.I grog
exits with error status
.B 1
if a macro package appears to be in use by the input document,
but
.I grog
was unable to infer which one,
or
.B 2
if there were problems handling an option or operand.
.
It otherwise exits with status
.BR 0 .
.
(If the
.B \-\-run
option is specified,
.IR groff 's
exit status is discarded.)
.
Inferring no preprocessors or macro packages is not an error condition;
a valid
.I roff
document need not use either.
.
Even plain text is valid input,
if one is mindful of the syntax of the control and escape characters.
.
.
.\" ====================================================================
.SH Examples
.\" ====================================================================
.
Running
.
.RS
.EX
.B grog @DOCDIR@/meintro.me
.EE
.RE
at the command line results in
.RS
.EX
groff \-me @DOCDIR@/meintro.me
.EE
.RE
.
because
.I grog
recognizes that the file
.I meintro.me
is written using macros from the
.I me
package.
.
The command
.
.RS
.EX
.B grog @DOCDIR@/pic.ms
.EE
.RE
.
outputs
.
.RS
.EX
groff \-e \-p \-t \-ms @DOCDIR@/pic.ms
.EE
.RE
.
on the other hand.
.
Besides discerning the
.I ms
macro package,
.I grog
recognizes that the file
.I pic.ms
additionally needs the combination of
.B \-t
for
.IR tbl ,
.B \-e
for
.IR eqn ,
and
.B \-p
for
.IR pic .
.
.
.\" XXX: grog no longer (June 2021) attempts to detect this scenario.
.\" It's also not a practical one; full-service macro packages don't
.\" generally support being "unloaded" for subsequent processing of
.\" another document using a different one.  We do achieve it, with
.\" care, in groff with man(7) and mdoc(7) (see andoc.tmac).
.\" .P
.\" If both of the former example files are combined in the command
.\" .
.\" .RS
.\" .EX
.\" .B grog meintro.me pic.ms
.\" .EE
.\" .RE
.\" .
.\" a diagnostic message is sent to the standard error stream because
.\" some macro packages cannot be combined.
.\" .
.\" Nevertheless the corresponding output with the wrong options is
.\" written to standard output:
.\" .
.\" .RS
.\" .EX
.\" groff \-t \-e \-p \-ms meintro.me pic.ms
.\" .EE
.\" .RE
.\" .
.\" and
.\" .I grog
.\" terminates with an error exit status.
.
.
.P
Consider a file
.IR \%doc/\:\%grnexampl.me ,
which uses the
.I @g@grn
preprocessor to include a
.MR gremlin 1
picture file in an
.I me \" generic
document.
.
Let's say we want to suppress color output,
produce a DVI file,
and get backtraces for any errors that
.I @g@troff
encounters.
.
The command
.
.RS
.EX
.B grog \-bc \-Idoc \-Tdvi doc/grnexmpl.me
.EE
.RE
.
is processed by
.I grog
into
.
.RS
.EX
groff \-bc \-Idoc \-Tdvi \-e \-g \-me doc/grnexmpl.me
.EE
.RE
.
where we can see that
.I grog
has inferred the
.I me \" generic
macro package along with the
.I eqn \" generic
and
.I grn \" generic
preprocessors.
.
(The input file is located in
.I @DOCDIR@
if you'd like to try this example yourself.)
.
.
.\" ====================================================================
.SH Authors
.\" ====================================================================
.
.I grog
was originally written in Bourne shell by James Clark.
.
The current implementation in Perl was written by
.MT groff\-bernd\:.warken\-72@\:web\:.de
Bernd Warken
.ME
and heavily revised by
.MT g.branden\:.robinson@\:gmail\:.com
G.\& Branden Robinson
.ME .
.
.
.\" ====================================================================
.SH "See also"
.\" ====================================================================
.
.MR groff @MAN1EXT@
.
.
.\" Restore compatibility mode (for, e.g., Solaris 10/11).
.cp \n[*groff_grog_1_man_C]
.do rr *groff_grog_1_man_C
.
.
.\" Local Variables:
.\" fill-column: 72
.\" mode: nroff
.\" End:
.\" vim: set filetype=groff textwidth=72: