-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakeidx.pp
88 lines (78 loc) · 1.58 KB
/
makeidx.pp
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
program makeidx;
var
t,f : text;
j : longint;
s : string;
begin
if paramcount<1 then
begin
writeln('Usage: makeidx <file>');
halt(1);
end;
assign(t,paramstr(1));
{I-}
reset(t);
{$I+}
if ioresult<>0 then
begin
Writeln('Can''t open ',paramstr(1));
Halt(1);
end;
assign(f,'makeidx.tmp');
rewrite(f);
s := '';
while (not eof(t)) and (pos('IDXSTART',s)=0) do
begin
readln(t,s);
writeln(f,s);
end;
s := '';
while (not eof(t)) and (pos('IDXEND',s)=0) do
readln(t,s);
while (not eof(t)) do
begin
readln(t,s);
{ remove <LI> }
if Copy(s,1,8)='<LI><A N' then
Delete(s,1,4);
{ Anchor ? }
if Copy(s,1,9)='<A NAME="' then
begin
Delete(s,1,9);
{</A>}
j:=pos('</A>',s);
if j=0 then
j:=255;
write(f,' <LI><A HREF="#'+Copy(s,1,j-1));
if j+4>=length(s) then
readln(t,s)
else
delete(s,1,j+3);
{<H3><LI>}
if Copy(s,1,2)='<H' then
Delete(s,1,4);
if Copy(s,1,2)='<L' then
Delete(s,1,4);
{</LI></H3>}
if Copy(s,length(s)-4,3)='</H' then
Delete(s,length(s)-4,5);
if Copy(s,length(s)-4,3)='</L' then
Delete(s,length(s)-4,5);
writeln(f,s+'</A></LI>');
end;
end;
writeln(f,'<!-- IDXEND -->');
reset(t);
s := '';
while (not eof(t)) and (pos('IDXEND',s)=0) do
readln(t,s);
while (not eof(t)) do
begin
readln(t,s);
writeln(f,s);
end;
close(t);
close(f);
erase(t);
rename(f,paramstr(1));
end.