[sword-svn] r348 - trunk/modules/perlconverters

chrislit at crosswire.org chrislit at crosswire.org
Wed Jan 18 21:30:00 MST 2012


Author: chrislit
Date: 2012-01-18 21:30:00 -0700 (Wed, 18 Jan 2012)
New Revision: 348

Modified:
   trunk/modules/perlconverters/usfm2osis.pl
Log:
consolidated code to trim leading/trailing whitespace and concatenate lines that don't begin with tags

Modified: trunk/modules/perlconverters/usfm2osis.pl
===================================================================
--- trunk/modules/perlconverters/usfm2osis.pl	2012-01-19 04:16:38 UTC (rev 347)
+++ trunk/modules/perlconverters/usfm2osis.pl	2012-01-19 04:30:00 UTC (rev 348)
@@ -194,6 +194,27 @@
     }
     close (SFM);
 
+    for ($i = 0; $i < scalar(@filedata);$i++) {
+	$line = @filedata[$i];
+	
+	### Trim leading/trailing whitespace
+#	$line =~ s/[\r\n]+//g;
+	$line =~ s/\s*$//;
+	$line =~ s/^\s*//;
+	
+	if ($line !~ /^\s*$/) {
+	    if ($line !~ /^\\/) {	
+		@filedata[$i-1] .= " $line";
+		splice(@filedata, $i, 1);
+		$i--
+	    }
+	    else {
+		@filedata[$i] = $line;
+	    }
+	}
+    }
+    
+    
     $ollevel = 0;
     $vers = 0;
     $chap = 0;
@@ -212,12 +233,7 @@
     #encoding stuff
     for ($i = 0; $i < scalar(@filedata); $i++) {
 	$line = @filedata[$i];
-	$line =~ s/[\r\n]//g;
 
-	### Trim leading/trailing whitespace
-	$line =~ s/\s*$//;
-	$line =~ s/^\s*//;
-
 	### Basic XML entity encoding
 	$line =~ s/&(?![a-zA-Z0-9])/&/g;
 	$line =~ s/<< ?/\@/g;




More information about the sword-cvs mailing list