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
|
#! /usr/bin/perl -w
# $Cambridge: exim/doc/doc-docbook/TidyInfo,v 1.2 2007/04/17 13:06:09 ph10 Exp $
# This is script to tidy up the Texinfo file that docbook2texi produces. We
# have to change "conceptindex" and "optionindex" to "cindex" and "findex", and
# we also have to add access to the index into the menus and a final node.
# Find the start of the first menu.
while (<>)
{
print;
last if /^\@menu/;
}
# Find the end of the first menu.
while (<>)
{
last if /^$/;
print;
}
# Insert a menu link to the index.
print "* Concept Index::\n\n";
# Find the final @bye line. En route, we look for the last chapter node, the
# one that has nothing following, and insert a pointer to an index node. Also,
# change the index names.
while (<>)
{
last if /^\@bye/;
if (/^\@node ([^,]+), , (.*)/)
{
my($save1) = $1;
my($save2) = $2;
my($saveline) = $_;
$_ = <>;
if (/^\@chapter/)
{
print "\@node $save1, Concept Index, $save2\n";
$previous = $save1;
}
else
{
print "$saveline";
}
print;
}
else
{
s/conceptindex/cindex/;
s/optionindex/findex/;
s/variableindex/findex/;
print;
}
}
# Insert the final index stuff at the end.
print "\@appendix\n";
print "\@node Concept Index, , $previous, Top\n";
print "\n\@printindex cp\n\n";
print;
# End
|