[sword-svn] r273 - trunk/modules/geneve

refdoc at crosswire.org refdoc at crosswire.org
Thu Jan 28 16:26:43 MST 2010


Author: refdoc
Date: 2010-01-28 16:26:43 -0700 (Thu, 28 Jan 2010)
New Revision: 273

Modified:
   trunk/modules/geneve/transform.pl
Log:
improvements to footnotes, swapping of some lines


Modified: trunk/modules/geneve/transform.pl
===================================================================
--- trunk/modules/geneve/transform.pl	2010-01-25 21:53:00 UTC (rev 272)
+++ trunk/modules/geneve/transform.pl	2010-01-28 23:26:43 UTC (rev 273)
@@ -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 @@
                 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 @@
 		
 		s/xid\=\".*?\"//g;
                 s/<.*?>//g;
-#                s/$/\n/;
 			              
 	}
 	@lines=split("\n",join("", at 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,11 +89,63 @@
 	        }
 	        
 	        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;
 }                                                                                  




More information about the sword-cvs mailing list