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

chrislit at crosswire.org chrislit at crosswire.org
Fri Sep 4 12:34:53 MST 2009


Author: chrislit
Date: 2009-09-04 12:34:53 -0700 (Fri, 04 Sep 2009)
New Revision: 212

Modified:
   trunk/modules/perlconverters/usfm2osis.pl
Log:
made Psalm titles canonical
made subsections produce a new <div>
added handling for subsections deeper than 3 levels


Modified: trunk/modules/perlconverters/usfm2osis.pl
===================================================================
--- trunk/modules/perlconverters/usfm2osis.pl	2009-08-29 21:50:09 UTC (rev 211)
+++ trunk/modules/perlconverters/usfm2osis.pl	2009-09-04 19:34:53 UTC (rev 212)
@@ -359,23 +359,36 @@
 	    openTag("<\/div type=\"section\">");
 	    $line =~ s/\\s1?\b\s*(.+)/<title>$1<\/title>/;
 	    if ($line =~ /HEBREW TITLE/) {
-		$line =~ s/<title>/<title type=\"psalm\">/;
+		$line =~ s/<title>/<title type=\"psalm\" canonical=\"true\">/;
 	    }
 	}
 
 	# \ss \s2 subSection (From Chapters and Verses)
 	if ($line =~ /^\\s[s2]\b\s*(.+)/) {
+	    push (@outdata, closeTag("<\/p>"));
+	    push (@outdata, closeTag("<\/div type=\"subSection\">"));
+	    push (@outdata, "<div type=\"subSection\">\n");
+	    openTag("<\/div type=\"subSection\">");
 	    $line =~ s/\\s[s2]\b\s*(.+)/<title>$1<\/title>/;
 	}
 
-	# \sss \s3 x-subsubSection (From Chapters and Verses)
-	if ($line =~ /^\\s(ss|3)\b\s*(.+)/) {
+	# \sss \s3 x-subSubSection (From Chapters and Verses)
+	# This will also handle deeper levels (4+) of subsections.
+	if ($line =~ /^\\s(ss|\d+)\b\s*(.+)/) {
+	    my $ssLvl = $1;
+	    my $ssType = "";
+	    while ($ssLvl > 2) {
+		$ssLvl--;
+		$ssType .= "Sub";
+	    }
+	    $ssType = "x-sub" . $ssType . "Section";
 	    push (@outdata, closeTag("<\/p>"));
-	    push (@outdata, closeTag("<\/div type=\"x=subSubSection\">"));
-	    push (@outdata, "<div type=\"x-subSubSection\">\n");
-	    openTag("<\/div type=\"x-subSubSection\">");
-	    $line =~ s/\\s(ss|3)\b\s*(.+)/<title>$2<\/title>/;
+	    push (@outdata, closeTag("<\/div type=\"$ssType\">"));
+	    push (@outdata, "<div type=\"$ssType\">\n");
+	    openTag("<\/div type=\"$ssType\">");
+	    $line =~ s/\\s(ss|\d+)\b\s*(.+)/<title>$2<\/title>/;
 	}
+
 	# \mt\mt1 title
 	if ($line =~ /^\\mt[1234]?\b\s*(.+)/) {
 	    $line = "<title type=\"main\">$1<\/title>";




More information about the sword-cvs mailing list