');
writeln(output,'');
clearstring(aline);
linkprocess := false;
potentiate := false;
comment := false;
seealsocount := 0;
while not eof(input) do begin
(* read in a line of text *)
getstring(input,aline,gotten);
if not gotten then begin
writeln(output,'htmlink: program error?');
halt
end;
resettrigger(seealso);
resettrigger(author);
for l := 1 to aline.length do begin
c := aline.letters[l];
testfortrigger(c, seealso);
if l = 8 then begin (* "see also" is 8 characters long *)
if seealso.found then begin
seealsocount := succ(seealsocount);
if seealsocount = 1 then potentiate := true;
end;
end;
testfortrigger(c, author);
if l = 6 then begin (* "author" is 8 characters long *)
if author.found then begin
linkprocess := false;
potentiate := false;
end;
end;
end;
if linkprocess then begin (* process the link section *)
(* parse out the named objects on one line *)
follow := 1;
pureurl := false;
c := ' ';
while follow <= aline.length do begin
{
writeln(output,'l=',follow:1);
}
cprevious := c;
c := aline.letters[follow];
insidecomment := (comment = true);
if c = '{' then comment := true;
if (cprevious <> escape) and (c = '}') then comment := false;
if c = ' ' then write(output,' ');
if c = ' ' then write(list,' ');
if insidecomment and (cprevious = escape) then begin
{
if cprevious = escape then begin
}
if c = '{' then write(output,'{');
if c = '{' then write(list,'{');
if c = '}' then write(output,'}');
if c = '}' then write(list,'}');
end;
if (c <> ' ') and (c <> ',')
and (c <> '{') and (c <> '}')
then begin
(* parse *)
resettrigger(http);
resettrigger(ftp);
resettrigger(gif);
resettrigger(jpg);
image := false;
l := follow;
{
writeln(output); write(output,'parsed string: "');
}
done := false;
while not done do begin
testfortrigger(aline.letters[l], http);
if http.found then pureurl := true;
testfortrigger(aline.letters[l], ftp);
if ftp.found then pureurl := true;
testfortrigger(aline.letters[l], gif);
if gif.found then image := true;
testfortrigger(aline.letters[l], jpg);
if jpg.found then image := true;
{
write(output,aline.letters[l]);
}
if (l = aline.length)
then done := true
else begin
l := succ(l);
if (aline.letters[l] = ' ') or
(aline.letters[l] = ',') or
(aline.letters[l] = '}') or
(aline.letters[l] = '{')
then begin
done := true;
l := pred(l); (* don't include that *)
end
end
end;
{
writeln(output,'"');
}
if comment then begin
writealine(output, aline, follow, l, escape);
writealine(list, aline, follow, l, escape);
end
else begin
(* if we just found *.p, write it out as HTML *)
if (aline.letters[l-1] = '.') and (aline.letters[l] = 'p')
then begin
write(output,''); (* replaces .p with .html *)
for i := follow to l do write(output,aline.letters[i]);
write(output,'');
for i := follow to l do write(list,aline.letters[i]);
end
else begin
if image then begin
write(output,'
');
if not image then begin
(* complete the link by giving it again: *)
for i := follow to l
do write(output,aline.letters[i]);
write(output,'');
end;
for i := follow to l
do write(list,aline.letters[i]);
end;
end;
follow := l; (* step parsing forward across the word *)
end;
if c = ',' then write(output,',');
follow := succ(follow);
end;
writeln(output);
writeln(list);
end
else begin (* just copy the line *)
writestring(output,aline);
writeln(output);
end;
(* this line had a "see also" so process the next line *)
if potentiate then linkprocess := true;
end;
writeln(output,'');
writeln(output,'');
writeln(output,'{