summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter von Kaehne <refdoc@gmx.net>2010-01-28 23:26:43 +0000
committerPeter von Kaehne <refdoc@gmx.net>2010-01-28 23:26:43 +0000
commit72948d8d91cf64cd00e80121420a72c6551f52e3 (patch)
treeba8eb46a9ccf704712dbd8946f2e0ca1dcd6b131
parent77caa80cc2a932a81d5d91d3a7897105e828fd7e (diff)
downloadsword-tools-72948d8d91cf64cd00e80121420a72c6551f52e3.tar.gz
improvements to footnotes, swapping of some lines
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@273 07627401-56e2-0310-80f4-f8cd0041bdcd
-rwxr-xr-xmodules/geneve/transform.pl86
1 files changed, 70 insertions, 16 deletions
diff --git a/modules/geneve/transform.pl b/modules/geneve/transform.pl
index 48aa657..c63296e 100755
--- a/modules/geneve/transform.pl
+++ b/modules/geneve/transform.pl
@@ -1,20 +1,22 @@
#!/usr/bin/perl
+sub footnote {
+ $return = $_[0];
+ $return =~ s/type=\"footnote_anchor\"\ style=\"\"\ xid=\".*?\"\ >//g;
+ $return =~ s/\[/\ \\add\ /g;
+ $return =~ s/\]/\ \\add\*\ /g;
+ $return =~ s/^\s*\(([0-9]+),([0-9]+)\)\s+/\ \\fr\ $1,$2\ \\ft\ /;
+ $return =~ s/(w|od|bed)\.\ /$1\.\ \\fqa\ /g;
+ $return =~ s/(\\fqa\ .*?)\\fqa/$1\ /g;
+ $return;
+}
+
my @files=`ls -1 *.abw`;
my @ident=`cat books`;
-
-
-
-
-
-
foreach (@files){
-
-
-
my @lines;
my %vs;
my %kw;
@@ -45,16 +47,15 @@ foreach (@files){
s/<m\ .*?\/m>//;
s/props\=\".*?\"//g;
s/<p\ style=\"Kapitel\".*?><c.*?>(.*?)<\/c><\/p>/\n\\c\ $1\ \n\\v\ 1\ \ /g;
- s/<p\ style=\"Psalm Nr\".*?><c.*?>Psalm\ (.*?)<\/c><\/p>/\n\\c\ $1\n\\s1\ Psalm\ $1\n/g;
+ s/<p\ style=\"Psalm Nr\".*?><c.*?>Psalm\ (.*?)<\/c>(<field.*?|)<\/p>$/\n\\c\ $1\n\\s1\ Psalm\ $1\ $2\n\\p/g;
s/<c\ style=\"Verszahl\".*?>(.*?)<\/c>/\n\\v\ $1\ \ /g;
s/<p\ style=\"Buchtitel\".*?>/\n\\mt\ /g;
s/<p\ style=\"Bucheinleitung\".*?>/\n\\imt\ Einleitung\n\\ip\ /g;
- s/<p\ style=\"Spaltentitel\".*?>(.*?)<\/p>/\n\\s2\ $1\n\\p\ /g;
- s/<p\ style=\"Spaltenparallelen\".*?>(.*?)<\/p>/\n\\r\ $1\n\\p\ /g;
+ s/<p\ style=\"Spaltentitel\".*?><c.*?>(.*?)<\/c>(<field.*?|)<\/p>/\n\\s2\ $1\ $2\n\\p/g;
+ s/<p\ style=\"Spaltenparallelen\".*?>(.*?)<\/p>/\n\\r\ $1/g;
s/<p style=\"Footnote Text\".*><field\ footnote-id=\".*?\"/\ \\f\ +\ /g;
s/<\/foot>/\\f\*\ /g;
s/type=\"footnote_anchor\"\ style=\"\"\ xid=\".*?\"\ >//g;
- s/\\r\ Kapitel/\\mr Kapitel/g;
if (!(/\\f.*?\[.*?\\f\*/)) {
s/\[/\ \\add\ /g;
}
@@ -68,17 +69,18 @@ foreach (@files){
s/xid\=\".*?\"//g;
s/<.*?>//g;
-# s/$/\n/;
}
@lines=split("\n",join("",@lines));
- my $chapter, $verse=0;
+ my $chapter, $verse=1;
+ my $c_found=0; # to sniff out single chapter books
foreach (@lines) {
if (/\\c\s+([0-9]+)\s/) {
$chapter=$1;
+ $c_found=1;
}
if (/\\v\s+([0-9]+)\s/) {
$verse=$1;
@@ -87,10 +89,62 @@ foreach (@files){
}
s/\\x\s+\\xk\s+(.+?)\s*\\x\*/$kw{$chapter.":".$verse.":".substr($1,0,4)}/eg;
- s/^\s*\\s2...$//;
+ s/\\f\ \+(.*?)\\f\*/"\\f +".footnote($1)." \\f*"/eg;
+
+ s/^\\r\s+(Kapitel|\(Psalm)/\\mr $1/g;
+
+
+ s/^\s*\\s2...$//;
+ s/\s+/\ /g;
s/$/\n/;
}
+ if ($c_found=0) {
+ foreach (@lines) {
+ s/\\v\ 1\s/\\c\ 1\n\\v\ 1\ /;
+ }
+ }
+
+ for ($i=0; $i<=@lines; $i++) {
+ if (@lines[$i]=~/^\\mr/) {
+ if (@lines[$i-2]=~/^\\s2/) {
+ my $s = @lines[$i-1];
+ @lines[$i-1] = @lines[$i];
+ @lines[$i] = $s;
+ @lines[$i-2] =~ s/\\s2/\\s/;
+ }
+ }
+ }
+ for ($i=0; $i<=@lines; $i++) {
+ if (@lines[$i]=~/^\\c/) {
+ if (@lines[$i-3]=~/^\\s2/) {
+ my $s = @lines[$i-3];
+ @lines[$i-3] = @lines[$i];
+ @lines[$i] = $s;
+ }
+ }
+ }
+ for ($i=0; $i<=@lines; $i++) {
+ if (@lines[$i]=~/^\\s2/) {
+ if (@lines[$i-1]=~/^\\r/) {
+ my $s = @lines[$i-2];
+ @lines[$i-2] = @lines[$i];
+ @lines[$i] = $s;
+ }
+ }
+ }
+ for ($i=0; $i<=@lines; $i++) {
+ if (@lines[$i]=~/^\\r/) {
+ if (@lines[$i-1]=~/^\\p/) {
+ if (@lines[$i-2]=~/^\\s2/) {
+ my $s = @lines[$i-1];
+ @lines[$i-1] = @lines[$i];
+ @lines[$i] = $s;
+ }
+
+ }
+ }
+ }
print (USFM @lines);
close USFM;