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