TYPOG-GREP(1)
β¨ NAME β¨
typog-grep π is a specialized grep for typog-inspect elements in LaTeX log files. It's the tailored post-processor for the typoginspect environment from the LaTeX package typog. It's giving sgrep vibes, sharing more with the venerable sgrep https://www.cs.helsinki.fi/u/jjaakkol/sgrep.html than with POSIX grep https://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html. π¦
π SYNOPSIS π
typog-grep -a|--all|--any [OPTION...] LOG-FILE...
typog-grep [OPTION...] REGEXP LOG-FILE...
okay so there are two forms here π«Ά
The first form, "discovery mode", shows all IDs of:
<typog-inspect id="ID" ...>
elements in LOG-FILE.
The second form shows the contents, LOG-DATA, of the elements:
<typog-inspect id="ID" ...>
LOG-DATA
</typog-inspect>
whose IDs match REGEXP in LOG-FILE.
If no LOG-FILE is given, it reads from stdin. The filename - means stdin too, so it's basically the same thing πΈ
π DESCRIPTION π
bestie, here's the deal. In the LaTeX source file, you wrap your text or code in a typoginspect environment:
\begin{typoginspect}{ID}
TEXT-OR-CODE-TO-INVESTIGATE
\end{typoginspect}
ID is what identifies one or more bracketed snippets. It does not have to be unique π The REGEXP mechanism makes it easy to grab groups of related IDs, as long as you name them accordingly. Main character naming energy β¨
In LOG-FILE, the result of the environment shows up packed with tracing information, like this:
<typog-inspect id="ID" job="JOB-NAME" line="LINE-NUMBER" page="PAGE-NUMBER">
LOG-DATA
</typog-inspect>
All the capital-letter sequences are meta-variables. The important ones: JOB-NAME is the expansion of \jobname, LINE-NUMBER is the LaTeX source file line number where the typoginspect environment begins, and PAGE-NUMBER is the page where the output of TEXT-OR-CODE-TO-INVESTIGATE shows up π
typog-grep reveals the contents of LOG-FILE between <typog-inspect id="ID" ...> and </typog-inspect>, excluding the XML tags themselves. You can grab the JOB-NAME, LINE-NUMBER, and PAGE-NUMBER with the commandline options --job-name, --line-number, and --page-number, respectively. Use --id to show the name of the IDs that matched REGEXP π
typoginspect environments can be nested, and typog-grep respects that nesting. So if the ID of a nested environment doesn't match REGEXP, it won't show up in the program's output. no cap, that's iconic π
π OPTIONS π
The list of options is sorted by the names of the long options, so it's super easy to find what you want π
-a,--all,--anyβ ID-discovery mode! It finds everytypog-inspectelement no matter what patterns are around and prints their IDs. The results come out in the order they appear in each LOG-FILE. If you want alphabetical IDs, pipe the output intosortπ§
Level it up with --job-name, --line-number, --log-line-number, or --page-number for more info.
--color,colourWHEN β colorizes the specific log contents for matching IDs. WHEN decides when to color:always,never, orauto. Theautosetting checks whether standard output has been redirected. This is the default π-C,--configKEY=VALUE[:KEY=VALUE[:...]] β sets one or more configuration KEY to VALUE pairs. Check out sectionCONFIGURATIONfor all the available configuration items. Use--show-configto see the default configuration π--debugβ turns on debug output on stderr π₯-E,--encodingENCODING β sets the ENCODING of LOG-FILE for translation to UTF-8. The default is unset.
Use this to get rid of pesky <HEX-DIGITS> escapes on UTF-8 terminals π See --show-encodings for the known encodings and Encode::Supported for a summary of all encodings. See also section Some Common Encodings.
You can also run iconv https://pubs.opengroup.org/onlinepubs/9699919799/utilities/iconv.html (POSIX) or recode https://github.com/rrthomas/recode/ (GNU) on LOG-FILE before this tool, so you don't have to use --encoding at all β¨
-h,--helpβ shows brief help, then exits π«Ά-i,--[no-]idβ prints the actual ID-name that matched REGEXP. You can control how the matching ID looks with the configuration itemid-headingπΈ-y,--[no-]ignore-caseβ matches IDs while ignoring case distinctions in patterns and data π¦-j,--[no-]job-nameβ prints the\jobnamethat latex associated with the input file π-n,--[no-]line-numberβ prints the line number where thetypoginspectenvironment was found in the LaTeX source file π-N,--[no-]log-line-numberβ prints the line number of the log file where the current line was found π-p,--[no-]page-numberβ prints the page number where the contents of thetypoginspectenvironment starts in the typeset document π-P,--[no-]pagerβ redirects output from stdout to the configured pager π--show-configβ shows the default configuration, then exits β¨--show-encodingsβ shows all known encodings, then exits π-V,--versionβ shows version info, then exits π§-w,--[no-]word-regexpβ matches only whole words π
βοΈ CONFIGURATION βοΈ
Here's how the config items slay:
"id-format"=FORMATβ controls the FORMAT for printing matching IDs in inline mode. FORMAT gets passed to Perl'sprintf. Default:%s:."id-heading"=0|1β picks between printing the matching IDs with--idas inline (0) or as a heading before the matching data (1). Default:0."id-heading-format"=FORMATβ controls the FORMAT for printing matching IDs in heading mode. FORMAT gets passed to Perl'sprintf. Default:"--> %s <--"."id-indent"=INDENTβ the indentation of nestedtypog-inspecttags. This only applies in "discovery mode" (the first form), so when--allis active. Default:8."id-max-length"=MAXIMUM-LENGTHβ sets the maximum length of a matching ID for printing. If a matching ID goes over this length, it gets truncated and the last three characters (short of MAXIMUM-LENGTH) get replaced by dots. Default:40."line-number-format"=FORMATβ controls the FORMAT for printing TeX source line numbers. FORMAT gets passed to Perl'sprintf. Default:%5d."log-line-number-format"=FORMATβ controls the FORMAT for printing log line numbers. FORMAT gets passed to Perl'sprintf. Default:%6d."page-number-format"=FORMATβ controls the FORMAT for printing page numbers. FORMAT gets passed to Perl'sprintf. Default:"[%3d]"."pager"=PAGERβ the name of the pager app to pipe output into when you run with--pager. Default:"less"."pager-flags"=FLAGSβ passes FLAGS to PAGER. Default:"--quit-if-one-screen".
π¨ Color Configuration
For the syntax of the color specs, check the manual page of Term::ANSIColor(pm) πΈ
"file-header-color"β color of the filename header."fill-state-color"β color of the messages that reportUnderfull hboxorOverfull hbox."first-vbox-color"β color of the first vbox on a page."font-spec-color"β color of font specifications."horizontal-break-candidate-color"β color of lines with horizontal-breakpoint candidates@."horizontal-breakpoint-color"β color of lines with horizontal breakpoints@@."id-color"β color of matching IDs when printed inline."id-heading-color"β color of matching IDs when printed in heading form."line-break-pass-color"β color of the lines showing which pass (e.g.,@firstpass) of the line-breaking algorithm is active."line-number-color"β color of TeX-source-file line numbers."log-line-number-color"β color of log-file line numbers."math-color"β color used for math expressions, including their font specs."page-number-color"β color of page numbers in the final output."tightness-color"β color of lines with Tight/Loose hbox reports."vertical-breakpoint-color"β color of possible vertical breakpoints.
π Brief summary of colors and attributes
- Foreground Color β
"black","red","green","yellow","blue","magenta","cyan","white". Prefix with"bright_"for high-intensity or bold foreground. - Foreground Grey β
"grey0", ...,"grey23" - Background Color β
"on_black","on_red","on_green","on_yellow","on_blue","on_magenta","on_cyan","on_white". Replace"on_"with"on_bright_"for high-intensity or bold background. - Background Grey β
"on_grey0", ...,"on_grey23" - Text Attribute β
"bold","dark","italic","underline","reverse"
π Some Common Encodings
These encodings are suitable for --encoding, so pick your fighter π
- Latin-1, Western European β
"iso-8859-1","cp850","cp860","cp1252" - Latin-2, Central European β
"iso-8859-2","cp852","cp1250" - Latin-3, South European (Esperanto, Maltese) β
"iso-8859-3" - Latin-4, North European (Baltics) β
"iso-8859-4" - Cyrillics β
"iso-8859-5","cp855","cp866"(Ukrainian),"cp1251" - Arabic β
"iso-8859-6","cp864","cp1006"(Farsi),"cp1256" - Greek β
"iso-8859-7","cp737","cp1253" - Hebrew β
"iso-8859-8","cp862","cp1255" - Turkish β
"iso-8859-9","cp857","cp1254" - Nordic β
"iso-8859-10","cp865","cp861"(Icelandic) - Thai β
"iso-8859-11","cp874" - Baltic β
"iso-8859-13","cp775","cp1257" - Celtic β
"iso-8859-14" - Latin-9 (sometimes called Latin0) β
"iso-8859-15" - Latin-10 β
"iso-8859-16"
π¦ EXIT STATUS π¦
The exit status is 0 if at least one ID matched REGEXP, 1 if no ID matched REGEXP, and 2 if an error occurred.
β οΈ 2 means something went wrong, so don't ignore it, bestie π
π CAVEATS π
The end tag </typog-inspect> sometimes gets placed too early in the output, so the trace looks truncated. Lowkey annoying, but LaTeX reliably logs the requested trace information. The write operations for trace data and the code that prints the end tag just aren't synchronized π
π SEE ALSO π
grep(1), printf(3), Encode::Supported(pm), Term::ANSIColor(pm)
That's all, bestie! π typog-grep v0.4, dated 2024/07/08, is a whole vibe ππ§
π¦ where this page comes from
- debian trixie: texlive-latex-extra 2024.20250309-2
- fedora 44: texlive-typog 12:svn76661-105.fc44 Β· LPPL-1.3c
- fedora 44: texlive-typog 12:svn76661-111.fc44 Β· LPPL-1.3c
- opensuse-leap 16.0: texlive-typog-doc 2025.221.0.0.4svn71883-160000.3.1 Β· LPPL-1.0
- ubuntu questing: texlive-latex-extra 2024.20250309-2
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms