summaryrefslogtreecommitdiffstats
path: root/modules/perlconverters/usfm2osis.pl
diff options
context:
space:
mode:
authorChris Little <chrislit@crosswire.org>2009-10-27 05:22:54 +0000
committerChris Little <chrislit@crosswire.org>2009-10-27 05:22:54 +0000
commit77cc879e18a646850317f248700c80fa9c7e5760 (patch)
tree8f0fe4786db9d933d4d57489378901f2085f3b54 /modules/perlconverters/usfm2osis.pl
parentb1af863f075ac2602d3348b8eaee3b852735b243 (diff)
downloadsword-tools-77cc879e18a646850317f248700c80fa9c7e5760.tar.gz
added \cl handling
improved \qr, \qs handling trimmed lots of extraneous whitespace git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@220 07627401-56e2-0310-80f4-f8cd0041bdcd
Diffstat (limited to 'modules/perlconverters/usfm2osis.pl')
-rw-r--r--modules/perlconverters/usfm2osis.pl32
1 files changed, 20 insertions, 12 deletions
diff --git a/modules/perlconverters/usfm2osis.pl b/modules/perlconverters/usfm2osis.pl
index 97e7d77..af8fc04 100644
--- a/modules/perlconverters/usfm2osis.pl
+++ b/modules/perlconverters/usfm2osis.pl
@@ -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 @@ foreach $file (@files) {
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])/&amp;/g;
@@ -425,8 +429,8 @@ foreach $file (@files) {
}
- ### 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 @@ foreach $file (@files) {
$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 @@ foreach $file (@files) {
# \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 @@ foreach $file (@files) {
$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 @@ foreach $file (@files) {
$note =~ s/\\ft\*//g;
# \f* Footnote closer
- $note =~ s/\\f\*//;
+ $note =~ s/\s*\\f\*//;
# \f Footnote opener
$note =~ s/\\f\b\s*([^\s]\s*)?//;