9b9f8f290f5645b0a56aff6748735e73a53007f1
[exim.git] / doc / doc-docbook / TidyInfo
1 #! /usr/bin/perl -w
2
3 # $Cambridge: exim/doc/doc-docbook/TidyInfo,v 1.1 2006/04/04 14:03:49 ph10 Exp $
4
5 # This is script to tidy up the Texinfo file that docbook2texi produces. We
6 # have to change "conceptindex" and "optionindex" to "cindex" and "findex", and
7 # we also have to add access to the index into the menus and a final node.
8
9 # Find the start of the first menu.
10
11 while (<>)
12 {
13 print;
14 last if /^\@menu/;
15 }
16
17 # Find the end of the first menu.
18
19 while (<>)
20 {
21 last if /^$/;
22 print;
23 }
24
25 # Insert a menu link to the index.
26
27 print "* Concept Index::\n\n";
28
29 # Find the final @bye line. En route, we look for the last chapter node, the
30 # one that has nothing following, and insert a pointer to an index node. Also,
31 # change the index names.
32
33 while (<>)
34 {
35 last if /^\@bye/;
36 if (/^\@node ([^,]+), , (.*)/)
37 {
38 my($save1) = $1;
39 my($save2) = $2;
40 my($saveline) = $_;
41 $_ = <>;
42 if (/^\@chapter/)
43 {
44 print "\@node $save1, Concept Index, $save2\n";
45 $previous = $save1;
46 }
47 else
48 {
49 print "$saveline";
50 }
51 print;
52 }
53 else
54 {
55 s/conceptindex/cindex/;
56 s/optionindex/findex/;
57 print;
58 }
59 }
60
61 # Insert the final index stuff at the end.
62
63 print "\@appendix\n";
64 print "\@node Concept Index, , $previous, Top\n";
65 print "\n\@printindex cp\n\n";
66
67 print;
68
69 # End