From 72948d8d91cf64cd00e80121420a72c6551f52e3 Mon Sep 17 00:00:00 2001 From: Peter von Kaehne Date: Thu, 28 Jan 2010 23:26:43 +0000 Subject: improvements to footnotes, swapping of some lines git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@273 07627401-56e2-0310-80f4-f8cd0041bdcd --- modules/geneve/transform.pl | 86 ++++++++++++++++++++++++++++++++++++--------- 1 file 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///; s/props\=\".*?\"//g; s/(.*?)<\/c><\/p>/\n\\c\ $1\ \n\\v\ 1\ \ /g; - s/Psalm\ (.*?)<\/c><\/p>/\n\\c\ $1\n\\s1\ Psalm\ $1\n/g; + s/Psalm\ (.*?)<\/c>($/\n\\c\ $1\n\\s1\ Psalm\ $1\ $2\n\\p/g; s/(.*?)<\/c>/\n\\v\ $1\ \ /g; s//\n\\mt\ /g; s//\n\\imt\ Einleitung\n\\ip\ /g; - s/(.*?)<\/p>/\n\\s2\ $1\n\\p\ /g; - s/(.*?)<\/p>/\n\\r\ $1\n\\p\ /g; + s/(.*?)<\/c>(/\n\\s2\ $1\ $2\n\\p/g; + s/(.*?)<\/p>/\n\\r\ $1/g; s/

/\\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; -- cgit