[sword-svn] r220 - trunk/modules/perlconverters
chrislit at crosswire.org
chrislit at crosswire.org
Mon Oct 26 22:22:54 MST 2009
Author: chrislit
Date: 2009-10-26 22:22:54 -0700 (Mon, 26 Oct 2009)
New Revision: 220
Modified:
trunk/modules/perlconverters/usfm2osis.pl
Log:
added \cl handling
improved \qr, \qs handling
trimmed lots of extraneous whitespace
Modified: trunk/modules/perlconverters/usfm2osis.pl
===================================================================
--- trunk/modules/perlconverters/usfm2osis.pl 2009-10-25 06:41:25 UTC (rev 219)
+++ trunk/modules/perlconverters/usfm2osis.pl 2009-10-27 05:22:54 UTC (rev 220)
@@ -4,7 +4,7 @@
## Licensed under the standard BSD license:
-# Copyright (c) 2002-2008 CrossWire Bible Society <http://www.crosswire.org/>
+# Copyright (c) 2002-2009 CrossWire Bible Society <http://www.crosswire.org/>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -40,12 +40,12 @@
#########################################################################
# Stores the script version and date
-$version = "1.6";
-$date = "2009-08-29";
+$version = "1.7";
+$date = "2009-10-26";
# Sets the version of OSIS used in the OSIS header
$osisVersion = "2.1.1";
# Stores the USFM Version
-$usfmVersion = "2.1"; # The USFM reference document can be found at http://confluence.ubs-icap.org/display/USFM/Home;jsessionid=97071C5C1E562036A1CAF4FF77147565 (as of 2008-07-07)
+$usfmVersion = "2.2"; # The USFM reference document can be found at http://www.ubs-icap.org/chm/usfm/2.2/ (as of 2009-10-26)
# This is the hash which maps the conversion of USFM book abbreviations to OSIS book abbreviations. ***I would like to add the ability to access an external file to provide options for other languages. In other words, in preparing a USFM file for conversion, a separate file could be created which could be used to map the conversion of abbreviated book names in other languages to OSIS. This would be especially useful for cross-references, but I haven't figured out how to do it yet.
%OSISbook = (
@@ -189,6 +189,10 @@
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;
@@ -425,8 +429,8 @@
}
- ### Chapters and Verses--Markers Supported: \c, \v, \vp...\vp*
- #### Markers Not Yet Supported: \ca...\ca*, \cl, \cp, \cd, \va...\va*
+ ### Chapters and Verses--Markers Supported: \c, \v, \vp...\vp*, \cl
+ #### Markers Not Yet Supported: \ca...\ca*, \cp, \cd, \va...\va*
# \c chapter
if ($line =~ /^\\c\b\s*([^ ]*)/) {
@@ -452,6 +456,11 @@
$line =~ s/\\c\b\s*([^ ]*)//;
}
+ # \cl chapter label
+ if ($line =~ /^\\cl\b\s*(.*)/) {
+ $line = "<title>$1<\/title>";
+ }
+
# \v verse
if ($line =~ /^\\v\b\s*(\d[^\\ ]*)?/) {
if ($1 ne "") {
@@ -540,7 +549,7 @@
# \qac...\qac*, acrostic character style (used within a line)
$line =~ s/\\qac\b\s*(.*?)\\qac\*/<hi type="acrostic">$1<\/hi>/g;
- # \q line
+ # \q line (including \q#, \qr, \qc, and \qs...\qs*)
if ($line =~ /^\\q/) {
if ($l != 1) {
push (@outdata, "<lg>\n");
@@ -569,16 +578,15 @@
$line =~ s/\\q\b\s*(.+)/<l>$1<\/l>/;
$line =~ s/\\qm?(\d+)\b\s*(.+)/<l level=\"$1\">$2<\/l>/;
$line =~ s/\\qc\b\s*(.+)/<l type=\"x-centered\">$1<\/l>/;
- if (@filedata[$i+1] !~ /\\q(?!t)/) {
+ $line =~ s/\\qr\b\s*(.+)/<l type=\"x-right\">$1<\/l>/;
+ $line =~ s/\\qs\b\s*(.+?)\s*\\qs\*/<l type="selah">$1<\/l>/;
+ if (@filedata[$i+1] !~ /\\q(?![ta])/) {
$line .= "\n<\/lg>";
$l = 0;
}
}
}
- # \qs...\qs*, Selah
- $line =~ s/\\qs\b\s*([^\\]+)\\qs\*/<l type="selah"> $1<\/l>/;
-
### Tables--Markers Supported: \tr, \th#, \tc#, \tcr#
####Markers Not Yet Supported: \thr#
@@ -696,7 +704,7 @@
$note =~ s/\\ft\*//g;
# \f* Footnote closer
- $note =~ s/\\f\*//;
+ $note =~ s/\s*\\f\*//;
# \f Footnote opener
$note =~ s/\\f\b\s*([^\s]\s*)?//;
More information about the sword-cvs
mailing list