#!/usr/bin/perl
#Converts Taeger text to HTML
print <<"endOfHeader";
Heliand
This is the Old Saxon Heliand. This text is based
primarily on the Monacensis manuscript, and follows the recension of
Otto Behaghel. See Taeger (1984) for a critical apparatus.
Taeger, Burkhard, ed. 1984. Heliand und Genesis.
Tuebingen: Max Niemeyer.
Click on the desired fitt.
endOfHeader
#If we can have only one version, let it be without italics, etc.:
#Italics highlight portions where different manuscripts or editors disagree;
# * marks beginning or end of manuscript fragments.
$lineNo = 0;
$wordNo = 0;
$prevFitt = 0;
while ($line = <>) {
chop $line;
if ($line =~ /^\W*$/) {
print OUT "$line
\n";
next;
}
$lineNo++;
$line =~ s/]+>//;
if ($line =~ /^(.*)(.*)$/) {
$pre = $1; $fittNo = $2; $post = $3;
if ($pre ne '') {&Write("${lineNo}a", $pre);}
$newFile = "fitt$fittNo.html";
print "Fitt $fittNo (from line $lineNo)
\n";
if ($prevFitt) {
print OUT "[Fitt $fittNo]\n";
&EndFitt;
}
open(OUT, ">fitts/$newFile") || die "Couldn't write to $newFile.";
print OUT "\n";
print OUT "Fitt $fittNo of the Heliand\n";
print OUT "\n";
print OUT "\n";
if ($prevFitt) {
print OUT
"[Back to Fitt $prevFitt]
\n";
}
print OUT "Fitt $fittNo
\n";
if ($pre ne '') {&Write("${lineNo}b", $post);}
else {&Write($lineNo, $post);}
$prevFitt = $fittNo;
} else {
&Write($lineNo, $line);
}
}
&EndFitt;
sub EndFitt {
print OUT "[Fitt index]\n";
print OUT "\n";
}
sub Write {
local($lineNo, $line) = @_;
#Commented out option uses italics and * to point to critical apparatus in
# Behaghel.
#$line =~ s/\[//g;
#$line =~ s/\]/<\/I>/g;
#This option is to delete refs to crit. app.: italics -> roman, delete
# stars:
$line =~ s/\[//g;
$line =~ s/\]//g;
$line =~ s/\*//g;
#Not all displays get these right. Is there a way to negotiate
# character sets?
$line =~ s/a\^/â/g;
$line =~ s/e\^/ê/g;
$line =~ s/i\^/î/g;
$line =~ s/o\^/ô/g;
$line =~ s/u\^/û/g;
$line =~ s/A\^/Â/g;
$line =~ s/E\^/Ê/g;
$line =~ s/I\^/Î/g;
$line =~ s/O\^/Ô/g;
$line =~ s/U\^/Û/g;
$line =~ s/a\/e/&ae;/g;
$line =~ s/d\//ð/g; #My Motif doesn't display this right
print OUT "$lineNo";
@words = split(/ +/, $line);
foreach $word (@words) {
if ($word =~ /\w/) {
$wordNo++;
print OUT " $word";
} else { #just punctuation, like | or ...
print OUT " $word";
}
$word =~ tr/A-Z/a-z/;
$word =~ s/^[^a-z]+//;
$word =~ s/[^a-z=\/^]$//;
if (defined $index{$word}) {
$index{$word} .= ";$fittNo-$wordNo";
} else {
$index{$word} = "$fittNo-$wordNo";
}
}
print OUT "
\n";
#print OUT "$lineNo $line
\n";
}
open(WINDEX, ">fitts/words") || die "Can't open fitts/words";
while (($word, $locs) = each %index) {
print WINDEX "$word: $locs\n";
}
print "\n";