Debian Codegraph @

texmf-dist/doc/latex/typog/typog-grep.pod

raw
1 =begin man
2
3 .\" Turn off justification.
4 .na
5
6 =end man
7
8 =head1 NAME
9
10 typog-grep - specialized grep for typog-inspect elements in LaTeX log files
11
12 =head1 SYNOPSIS
13
14 =over
15
16 =item B<typog-grep> -a|--all|--any [I<OPTION>...] F<LOG-FILE>...
17
18 =item B<typog-grep> [I<OPTION>...] I<REGEXP> F<LOG-FILE>...
19
20 =back
21
22 The first form, ``discovery mode'', shows all I<ID>s of
23
24 =begin text
25
26 <typog-inspect id="ID" ...>
27
28 =end text
29
30 =begin man
31
32 .RS
33 .EX
34 <typog-inspect id="\fI\,ID\/\fP" ...>
35 .EE
36 .RE
37
38 =end man
39
40 =begin texinfo
41
42 @example
43 <typog-inspect id="@var{ID}" ...>
44 @end example
45 @noindent
46
47 =end texinfo
48
49 Z<>
50 elements in F<LOG-FILE>.
51
52 The second form shows the contents, I<LOG-DATA>, of the elements
53
54 =begin text
55
56 <typog-inspect id="ID" ...>
57 LOG-DATA
58 </typog-inspect>
59
60 =end text
61
62 =begin man
63
64 .RS
65 .EX
66 <typog-inspect id="\fI\,ID\/\fP" ...>
67 \fILOG-DATA\fP
68 </typog-inspect>
69 .EE
70 .RE
71
72 =end man
73
74 =begin texinfo
75
76 @example
77 <typog-inspect id="@var{ID}" ...>
78 @var{LOG-DATA}
79 </typog-inspect>
80 @end example
81 @noindent
82
83 =end texinfo
84
85 Z<>
86 whose I<ID>s match I<REGEXP> in F<LOG-FILE>.
87
88 If no F<LOG-FILE> is given read from F<stdin>.
89 The S<filename C<->> is synonymous to F<stdin>.
90
91 =head1 DESCRIPTION
92
93 B<typog-grep> is a tailored post-processor for LaTeX S<F<log> files>
94 and the C<typoginspect> environment as provided by the S<LaTeX package typog>.
95 It shares more with the venerable
96 L<B<sgrep>|https://www.cs.helsinki.fi/u/jjaakkol/sgrep.html>
97 than with S<POSIX L<B<grep>|https://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html>>.
98
99 In the LaTeX source file the user brackets her text or code
100 in a C<typoginspect> environment:
101
102 =begin text
103
104 \begin{typoginspect}{ID}
105 TEXT-OR-CODE-TO-INVESTIGATE
106 \end{typoginspect}
107
108 =end text
109
110 =begin man
111
112 .RS
113 .EX
114 \ebegin{typoginspect}{\fI\,ID\/\fP}
115 \fITEXT-OR-CODE-TO-INVESTIGATE\fP
116 \eend{typoginspect}
117 .EE
118 .RE
119
120 =end man
121
122 =begin texinfo
123
124 @example
125 @backslashchar{}begin@lbracechar{}typoginspect@rbracechar{}@lbracechar{}@var{ID}@rbracechar{}
126 @var{TEXT-OR-CODE-TO-INVESTIGATE}
127 @backslashchar{}end@lbracechar{}typoginspect@rbracechar{}
128 @end example
129 @noindent
130
131 =end texinfo
132
133 Z<>
134 where I<ID> is used to identify one or more bracketed snippets.
135 I<ID> does not have to be unique.
136 The I<REGEXP> mechanism makes it easy to select groups of related I<ID>s
137 if they are named accordingly.
138
139 In F<LOG-FILE> the result of the environment shows up,
140 packed with tracing information, as
141
142 =begin text
143
144 <typog-inspect id="ID" job="JOB-NAME" line="LINE-NUMBER" page="PAGE-NUMBER">
145 LOG-DATA
146 </typog-inspect>
147
148 =end text
149
150 =begin man
151
152 .RS
153 .EX
154 <typog-inspect id="\fI\,ID\/\fP" job="\fI\,JOB-NAME\/\fP" line="\fI\,LINE-NUMBER\/\fP" page="\fI\,PAGE-NUMBER\/\fP">
155 \fILOG-DATA\fP
156 </typog-inspect>
157 .EE
158 .RE
159
160 =end man
161
162 =begin texinfo
163
164 @example
165 <typog-inspect id="@var{ID}" job="@var{JOB-NAME}" line="@var{LINE-NUMBER}" page="@var{PAGE-NUMBER}">
166 @var{LOG-DATA}
167 </typog-inspect>
168 @end example
169 @noindent
170
171 =end texinfo
172
173 Z<>
174 where all the capital-letter sequences are meta-variables
175 and in particular
176 I<JOB-NAME> is the expansion of C<\jobname>,
177 I<LINE-NUMBER> is the LaTeX source file line number
178 of the beginning of the C<typoginspect> environment,
179 and I<PAGE-NUMBER> is the page where
180 the output of S<C<TEXT-OR-CODE-TO-INVESTIGATE>> occurs.
181
182 B<typog-grep> reveals the contents of F<LOG-FILE>
183 between C<E<lt>typog-inspect id="I<ID>" ...E<gt>>
184 and C<E<lt>/typog-inspectE<gt>> excluding the XML-tags themselves.
185 Access the I<JOB-NAME>, I<LINE-NUMBER>, and I<PAGE-NUMBER>
186 with the commandline options
187 B<--job-name>, B<--line-number>, and B<--page-number>.
188 Use B<--id> to show the name of the IDs that matched I<REGEXP>.
189
190 C<typoginspect> environments can be nested.
191 B<typog-grep> respects the nesting,
192 i.e., if the I<ID> of the nested environment does not match I<REGEXP>
193 it will not be included in the program's output.
194
195 =head1 OPTIONS
196
197 The list of options is sorted by the names of the long options.
198
199 =over 4
200
201 =item B<-a>, B<--all>, B<--any>
202
203 ID-discovery mode:
204 Discover all C<typog-inspect> elements independent of any matching patterns
205 and print their I<ID>s.
206 The results are printed in their order of occurrence in the F<LOG-FILE>s.
207 Pipe the output into B<sort> to get alphabetically ordered I<ID>s.
208
209 Augment with options
210 B<--job-name>, B<--line-number>, B<--log-line-number>, or S<B<--page-number>>
211 for more information.
212
213 =item B<--color>, B<colour> I<WHEN>
214
215 Colorize specific log contents for the matching I<ID>s.
216 The S<argument I<WHEN>> determines when to apply color:
217 C<always>, C<never>, S<or C<auto>>.
218 The setting C<auto> checks whether standard output has been redirected.
219 This is the default.
220
221 =item B<-C>, B<--config> I<KEY>=I<VALUE>[:I<KEY>=I<VALUE>[:...]]
222
223 Set one or more configuration I<KEY> to I<VALUE> pairs.
224 See section L</CONFIGURATION> for a description
225 of all available configuration items.
226 Use S<option B<--show-config>> to display the default configuration.
227
228 =item B<--debug>
229
230 Turn on debug output on F<stderr>.
231
232 =item B<-E>, B<--encoding> I<ENCODING>
233
234 Set the I<ENCODING> of F<LOG-FILE> for the translation to UTF-8.
235 The default is unset.
236
237 Use this option to get rid of pesky
238 S<"E<lt>I<HEX-DIGITS>E<gt>" escapes> on UTF-8 terminals.
239 See S<option B<--show-encodings>> for the known encodings and
240 Encode::Supported for a summary of all encodings.
241 See also S<section L</Some Common Encodings>>.
242
243 Apply L<B<iconv>|https://pubs.opengroup.org/onlinepubs/9699919799/utilities/iconv.html>
244 (POSIX) or L<B<recode>|https://github.com/rrthomas/recode/> (GNU) on F<LOG-FILE>
245 before this tool to avoid having to use S<option B<--encoding>>.
246
247 =item B<-h>, B<--help>
248
249 Display brief help then exit.
250
251 =item B<-i>, B<--[no-]id>
252
253 Print the actual ID-name that matched I<REGEXP>.
254 Control the appearance of the matching I<ID> with configuration S<item C<id-heading>>.
255
256 =item B<-y>, B<--[no-]ignore-case>
257
258 Match I<ID>s while ignoring case distinctions in patterns and data.
259
260 =item B<-j>, B<--[no-]job-name>
261
262 Print the C<\jobname> that B<latex> associated with the input file.
263
264 =item B<-n>, B<--[no-]line-number>
265
266 Print the line number where the S<C<typoginspect> environment>
267 was encountered in the LaTeX source file.
268
269 =item B<-N>, B<--[no-]log-line-number>
270
271 Print the line number of the F<log>-file where the current line was encountered.
272
273 =item B<-p>, B<--[no-]page-number>
274
275 Print page number where the contents of the S<C<typoginspect> environment>
276 starts in the typeset document.
277
278 =item B<-P>, B<--[no-]pager>
279
280 Redirect output from F<stdout> to the configured pager.
281
282 =item B<--show-config>
283
284 Show the default configuration and exit.
285
286 =item B<--show-encodings>
287
288 Show all known encodings and exit.
289
290 =item B<-V>, B<--version>
291
292 Show version information and exit.
293
294 =item B<-w>, B<--[no-]word-regexp>
295
296 Match only whole words.
297
298 =back
299
300 =head1 CONFIGURATION
301
302 =over 4
303
304 =item C<id-format>=I<FORMAT>
305
306 Control the I<FORMAT> for printing matching ids in inline-mode,
307 where I<FORMAT> is passed to Perl's C<printf>.
308 S<Default: C<%s:>.>
309
310 =item C<id-heading>=C<0>E<verbar>C<1>
311
312 Choose between printing the matching I<ID>s with S<option B<--id>>:
313 S<Inline (C<0>)> or heading before the matching data (C<1>).
314 S<Default: C<0>.>
315
316 =item C<id-heading-format>=I<FORMAT>
317
318 Control the I<FORMAT> for printing matching I<ID>s in heading-mode,
319 where I<FORMAT> is passed to Perl's C<printf>.
320 S<Default: C<--E<gt> %s E<lt>-->.>
321
322 =item C<id-indent>=I<INDENT>
323
324 Indentation of nested typog-inspect tags.
325 Only used in ``discovery mode'' (first form), i.e., if S<B<--all>> is active.
326 S<Default: 8.>
327
328 =item C<id-max-length>=I<MAXIMUM-LENGTH>
329
330 Set the maximum length of a matching I<ID> for printing.
331 It a matching I<ID> exceeds this length it will be truncated
332 and the last three characters (short of I<MAXIMUM-LENGTH>) will be replaced by dots.
333 S<Default: 40.>
334
335 =item C<line-number-format>=I<FORMAT>
336
337 Control the I<FORMAT> for printing TeX source line numbers,
338 where I<FORMAT> is passed to Perl's C<printf>.
339 S<Default: C<%5d>.>
340
341 =item C<log-line-number-format>=I<FORMAT>
342
343 Control the I<FORMAT> for printing log line numbers,
344 where I<FORMAT> is passed to Perl's C<printf>.
345 S<Default: C<%6d>.>
346
347 =item C<page-number-format>=I<FORMAT>
348
349 Control the I<FORMAT> for printing page numbers,
350 where I<FORMAT> is passed to Perl's C<printf>.
351 S<Default: C<[%3d]>.>
352
353 =item C<pager>=I<PAGER>
354
355 Name of pager application to pipe output into
356 if run with S<option B<--pager>>.
357 S<Default: C<less>>.
358
359 =item C<pager-flags>=I<FLAGS>
360
361 Pass I<FLAGS> to I<PAGER>.
362 S<Default: C<--quit-if-one-screen>>.
363
364 =item Color Configuration
365
366 For the syntax of the color specifications consult
367 the manual page of Term::ANSIColor(pm).
368
369 =over 4
370
371 =item C<file-header-color>
372
373 Color of the filename header.
374
375 =item C<fill-state-color>
376
377 Color of the messages that report ``Underfull hbox'' or ``Overfull hbox''.
378
379 =item C<first-vbox-color>
380
381 Color of the first vbox on a page.
382
383 =item C<font-spec-color>
384
385 Color of font specifications.
386
387 =item C<horizontal-break-candidate-color>
388
389 Color of lines with horizontal-breakpoint S<candidates C<@>>.
390
391 =item C<horizontal-breakpoint-color>
392
393 Color of lines with horizontal S<breakpoints C<@@>>.
394
395 =item C<id-color>
396
397 Color of matching I<ID>s when printed inline.
398
399 =item C<id-heading-color>
400
401 Color of matching I<ID>s when printed in heading form.
402
403 =item C<line-break-pass-color>
404
405 Color of the lines showing which pass (e.g., C<@firstpass>)
406 of the line-breaking algorithm is active.
407
408 =item C<line-number-color>
409
410 Color of TeX-source-file line numbers.
411
412 =item C<log-line-number-color>
413
414 Color of log-file line numbers.
415
416 =item C<math-color>
417
418 Color used for math expressions including their font specs.
419
420 =item C<page-number-color>
421
422 Color of page numbers of the final output.
423
424 =item C<tightness-color>
425
426 Color of lines with Tight/Loose hbox reports.
427
428 =item C<vertical-breakpoint-color>
429
430 Color of possible vertical breakpoints.
431
432 =back
433
434 =back
435
436 =head2 Brief summary of colors and attributes
437
438 =over 4
439
440 =item Foreground Color
441
442 C<black>, C<red>, C<green>, C<yellow>,
443 C<blue>, C<magenta>, C<cyan>, C<white>,
444
445 Prefix with C<bright_> for high-intensity or bold foreground.
446
447 =item Foreground Grey
448
449 C<grey0>, ..., C<grey23>
450
451 =item Background Color
452
453 C<on_black>, C<on_red>, C<on_green>, C<on_yellow>,
454 S<C<on_blue>>, S<C<on_magenta>>, S<C<on_cyan>>, S<C<on_white>>
455
456 Replace C<on_> with C<on_bright_> for high-intensity or bold background.
457
458 =item Background Grey
459
460 C<on_grey0>, ..., C<on_grey23>
461
462 =item Text Attribute
463
464 C<bold>, C<dark>, C<italic>, C<underline>, C<reverse>
465
466 =back
467
468 =head2 Some Common Encodings
469
470 The following list shows some encodings
471 that are suitable for S<option B<--encoding>>.
472
473 =over 4
474
475 =item Latin-1, Western European
476
477 C<iso-8859-1>, C<cp850>, C<cp860>, C<cp1252>
478
479 =item Latin-2, Central European
480
481 C<iso-8859-2>, C<cp852>, C<cp1250>
482
483 =item Latin-3, South European (Esperanto, Maltese)
484
485 C<iso-8859-3>
486
487 =item Latin-4, North European (Baltics)
488
489 C<iso-8859-4>
490
491 =item Cyrillics
492
493 C<iso-8859-5>, C<cp855>, C<cp866> (Ukrainian), C<cp1251>
494
495 =item Arabic
496
497 C<iso-8859-6>, C<cp864>, C<cp1006> (Farsi), C<cp1256>
498
499 =item Greek
500
501 C<iso-8859-7>, C<cp737>, C<cp1253>
502
503 =item Hebrew
504
505 C<iso-8859-8>, C<cp862>, C<cp1255>
506
507 =item Turkish
508
509 C<iso-8859-9>, C<cp857>, C<cp1254>
510
511 =item Nordic
512
513 C<iso-8859-10>, C<cp865>, C<cp861> (Icelandic)
514
515 =item Thai
516
517 C<iso-8859-11>, C<cp874>
518
519 =item Baltic
520
521 C<iso-8859-13>, C<cp775>, C<cp1257>
522
523 =item Celtic
524
525 C<iso-8859-14>
526
527 =item Latin-9 (sometimes called Latin0)
528
529 C<iso-8859-15>
530
531 =item Latin-10
532
533 C<iso-8859-16>
534
535 =back
536
537 =head1 EXIT STATUS
538
539 The exit status is 0 if at least one I<ID> matched I<REGEXP>,
540 1 if no I<ID> matched I<REGEXP>, and 2 if an error occurred.
541
542 =head1 CAVEATS
543
544 The end tag C<< </typog-inspect> >> sometimes gets placed too early in the output and the trace
545 I<seems> truncated. However, LaTeX reliably logs the requested the trace information, but the
546 write operations for trace data and the code which is used to print the S<end tag> are not
547 synchronized.
548
549 =head1 SEE ALSO
550
551 B<grep>(1), B<printf>(3), B<Encode::Supported>(pm), B<Term::ANSIColor>(pm)
552
553 =cut