diff options
author | Akira Yokosawa <akiyks@gmail.com> | 2022-01-18 19:52:14 +0900 |
---|---|---|
committer | Paul E. McKenney <paulmck@kernel.org> | 2022-01-18 09:31:31 -0800 |
commit | 1770273b3fa06a9d0e7b2806be67929dcc2a76b3 (patch) | |
tree | 5bb8a940195268d3e5652a87b6002703d9c0021b /utilities | |
parent | bf4794df366d2cf87c2e9cf177f5169081138a23 (diff) | |
download | perfbook-1770273b3fa06a9d0e7b2806be67929dcc2a76b3.tar.gz |
index: Initial page number format support
If plain \index{} macro were used for tagging terms, one could
say:
\index{some word|textbf}
to have a page number in bold face.
However, existing indexing scheme conflicts with makeindex's page
number formatting and naively defined macros of \IXB{} and its
variants don't produce proper-format .idx files.
As a workaround, use a helper script "adjustindexformat.pl" to
overcome the conflict.
Adjusted .idx file is kept as $basename-adjust.idx.
See header comments of adjustindexformat.pl for adjustment samples.
Note: $basename.idx is overwritten by the final run of pdflatex.
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'utilities')
-rwxr-xr-x | utilities/adjustindexformat.pl | 33 | ||||
-rw-r--r-- | utilities/runlatex.sh | 2 |
2 files changed, 35 insertions, 0 deletions
diff --git a/utilities/adjustindexformat.pl b/utilities/adjustindexformat.pl new file mode 100755 index 00000000..6cdc8c8f --- /dev/null +++ b/utilities/adjustindexformat.pl @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Adjust index entry format in .idx file generated by \IXB{} and +# its variants. +# +# Adjustment samples (diff): +# +# -\indexentry{deadlock|hyperindexformat{\bf@\makefirstuc {deadlock|bf}}}{228} +# +\indexentry{deadlock@\makefirstuc {deadlock}|hyperindexformat{\BF}}{228} +# -\indexentry{read-copy update (RCU)@\makefirstuc {read-copy update} [RCU]|hyperpage}{306} +# +\indexentry{read-copy update (RCU)@\makefirstuc {read-copy update} (RCU)|hyperindexformat{\BF}}{306} +# -\indexentry{critical section|hyperindexformat{\bf@\makefirstuc {critical section|bf}!RCU read-side}}{325} +# +\indexentry{critical section@\makefirstuc {critical section}!RCU read-side|hyperindexformat{\BF}}{325} +# +# Copyright (C) Akira Yokosawa, 2022 +# +# Authors: Akira Yokosawa <akiyks@gmail.com> + +use strict; +use warnings; + +my $line; + +open(my $fh, '<:encoding(UTF-8)', $ARGV[0]) + or die "Could not open file '$ARGV[0]' $!"; + +while($line = <$fh>) { + $line =~ s/\{([^\|]+)(\|hyperindexformat)\{\\bf(@\\makefirstuc )\{.+\}\}\}/\{$1$3\{$1\}$2\{\\BF\}\}/ ; + $line =~ s/\{([^\|]+)(\|hyperindexformat)\{\\bf(@\\makefirstuc )\{.+\}!([^\}]+)\}\}/\{$1$3\{$1}!$4$2\{\\BF\}\}/ ; + $line =~ s/(\\makefirstuc )\{([^\)]+)\} \[([^\]]+)\]\|hyperpage\}/$1\{$2\} \($3\)|hyperindexformat\{\\BF\}\}/ ; + print $line ; +} diff --git a/utilities/runlatex.sh b/utilities/runlatex.sh index 37636f07..48761fd0 100644 --- a/utilities/runlatex.sh +++ b/utilities/runlatex.sh @@ -64,6 +64,8 @@ exerpt_warnings () { } iterate_latex () { + perl utilities/adjustindexformat.pl $basename.idx > $basename-adjust.idx + cp -f $basename-adjust.idx $basename.idx makeindex $basename.idx > /dev/null 2>&1 makeindex $basename-api.idx > /dev/null 2>&1 if grep -q '## Warning' $basename.ilg $basename-api.ilg |