-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-html.pl
51 lines (51 loc) · 967 Bytes
/
make-html.pl
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
#! perl -w
while(<>){
chomp;
# pipe from output run-dbplay-on-no-parent.pl
if(/^mainline (.*)/){
$mainline=$1;
} elsif($_ eq 'three-fold repetition'){
$draw_reason=$_;
} elsif(/^outcome (.*)/){
$outcome=$1;
} elsif(/^san (.*)/){
$san=$1;
} elsif ($_ eq 'fifty move rule'){
$draw_reason=$_;
} elsif ($_ eq 'mate') {
#ignore
} else {
die "weird '$_'";
}
}
$mainline=~s!\s*\|\s*! !;
$mainline =~s/^\s*//;
print "$mainline ::"; #for sorting;
@F=split for($san);
$out=0;
$seen_bar=0;
for(@F){
if($_ eq '|'){
$seen_bar=1;
next;
}
print " " unless ($out==0);
unless($seen_bar){
print "<b>";
}
if($out%2==0){
print $out/2+1,".";
}
print$_;
$out++;
unless($seen_bar){
print "</b>";
}
}
print " ";
if($outcome eq '1/2'){
print "1/2-1/2 {$draw_reason}";
} else {
print $outcome;
}
print "\n";