Commit | Line | Data |
---|---|---|
495ae4b0 | 1 | #! /usr/bin/perl -w |
495ae4b0 PH |
2 | |
3 | $style = (@ARGV > 0)? $ARGV[0] : "a4ps"; | |
4 | ||
5 | open(IN, "z-rawindex") || die "Can't open z-rawindex\n"; | |
6 | open(OUT, ">z-contents") || die "Can't open z-contents\n"; | |
7 | ||
8 | print OUT <<'EOF'; | |
9 | .if ~~sys.fancy | |
10 | .linelength ~~sys.linelength + 0.2in | |
11 | .pagedepth ~~sys.pagedepth - 0.2in | |
12 | .linedepth 12.24 | |
13 | .fi | |
14 | .include "markup.sg" | |
15 | .set chapter -1 | |
16 | .set p 0 | |
17 | .format p roman | |
18 | .tabset 2em 2em | |
19 | . | |
20 | .foot | |
21 | .set p ~~sys.pagenumber | |
22 | $c [~~p] | |
23 | .endfoot | |
24 | . | |
25 | .chapter Contents | |
26 | .disable filling | |
27 | .justify left | |
28 | EOF | |
29 | ||
30 | while(<IN>) | |
31 | { | |
32 | if (/\$e/) | |
33 | { | |
34 | s/\$e\s*$//; # "see also" lines have no line number | |
35 | s/--\s*\d+$//; # remove "extra" number for index page | |
36 | ||
37 | s/\n$//; # trailing newline | |
38 | ||
39 | if (!/^\$/) | |
40 | { | |
41 | print OUT ".blank\n"; | |
42 | print OUT ".if ~~sys.leftonpage < 2*~~sys.linedepth\n"; | |
43 | print OUT ".newpage\n"; | |
44 | print OUT ".fi\n"; | |
45 | print OUT "\$shead\{$_\}\n"; | |
46 | print OUT ".blank\n"; | |
47 | } | |
48 | else | |
49 | { | |
50 | print OUT "$_\n"; | |
51 | } | |
52 | } | |
53 | } | |
54 | ||
55 | close(IN); | |
56 | close(OUT); | |
57 | ||
58 | system("sgcal z-contents -to zc-gcode -style $style -index /dev/null"); | |
59 | if ($style eq "a4ps") | |
60 | { | |
61 | system("sgtops zc-gcode -to zc-ps"); | |
62 | print "PostScript in zc-ps\n"; | |
63 | } | |
64 | else | |
65 | { | |
66 | system("mv -f zc-gcode zc-txt"); | |
67 | print "Text in zc-txt\n"; | |
68 | } | |
69 | ||
70 | # End |