blob: 76b2da0794a704fc03edc1f39e5b3d18fb3a68f5 (
plain)
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
$style = (@ARGV > 0)? $ARGV[0] : "a4ps";
open(IN, "z-rawindex") || die "Can't open z-rawindex\n";
open(OUT, ">z-contents") || die "Can't open z-contents\n";
print OUT <<'EOF';
.if ~~sys.fancy
.linelength ~~sys.linelength + 0.2in
.pagedepth ~~sys.pagedepth - 0.2in
.linedepth 12.24
.fi
.include "markup.sg"
.set chapter -1
.set p 0
.format p roman
.tabset 2em 2em
.
.foot
.set p ~~sys.pagenumber
$c [~~p]
.endfoot
.
.chapter Contents
.disable filling
.justify left
EOF
while(<IN>)
{
if (/\$e/)
{
s/\$e\s*$//; # "see also" lines have no line number
s/--\s*\d+$//; # remove "extra" number for index page
s/\n$//; # trailing newline
if (!/^\$/)
{
print OUT ".blank\n";
print OUT ".if ~~sys.leftonpage < 2*~~sys.linedepth\n";
print OUT ".newpage\n";
print OUT ".fi\n";
print OUT "\$shead\{$_\}\n";
print OUT ".blank\n";
}
else
{
print OUT "$_\n";
}
}
}
close(IN);
close(OUT);
system("sgcal z-contents -to zc-gcode -style $style -index /dev/null");
if ($style eq "a4ps")
{
system("sgtops zc-gcode -to zc-ps");
print "PostScript in zc-ps\n";
}
else
{
system("mv -f zc-gcode zc-txt");
print "Text in zc-txt\n";
}
# End
|