1#!/usr/bin/perl -w
2
3my @menu = ();
4my $output = $ARGV[0];
5
6open TMP, '>', "$output.tmp";
7
8while (<STDIN>) {
9 next if (/^\\input texinfo/../\@node Top/);
10 next if (/^\@bye/ || /^\.ft/);
11 if (s/^\@top (.*)/\@node $1,,,Top/) {
12 push @menu, $1;
13 }
14 s/\(\@pxref{\[(URLS|REMOTES)\]}\)//;
15 s/\@anchor\{[^{}]*\}//g;
16 print TMP;
17}
18close TMP;
19
20printf '\input texinfo
21@setfilename gitman.info
22@documentencoding UTF-8
23@dircategory Development
24@direntry
25* Git Man Pages: (gitman). Manual pages for Git revision control system
26@end direntry
27@node Top,,, (dir)
28@top Git Manual Pages
29@documentlanguage en
30@menu
31', $menu[0];
32
33for (@menu) {
34 print "* ${_}::\n";
35}
36print "\@end menu\n";
37open TMP, '<', "$output.tmp";
38while (<TMP>) {
39 print;
40}
41close TMP;
42print "\@bye\n";
43unlink "$output.tmp";