summaryrefslogtreecommitdiffstats
path: root/modules/perlconverters
diff options
context:
space:
mode:
authorChris Little <chrislit@crosswire.org>2012-01-19 04:30:00 +0000
committerChris Little <chrislit@crosswire.org>2012-01-19 04:30:00 +0000
commit118e164e50bd49d57bce9f5132aff37f300caea6 (patch)
tree909047067193240f3a58f15f6477a9a6862f377e /modules/perlconverters
parent6f5af54a493f245462283abfa12b202ed717f535 (diff)
downloadsword-tools-118e164e50bd49d57bce9f5132aff37f300caea6.tar.gz
consolidated code to trim leading/trailing whitespace and concatenate lines that don't begin with tags
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@348 07627401-56e2-0310-80f4-f8cd0041bdcd
Diffstat (limited to 'modules/perlconverters')
-rw-r--r--modules/perlconverters/usfm2osis.pl26
1 files changed, 21 insertions, 5 deletions
diff --git a/modules/perlconverters/usfm2osis.pl b/modules/perlconverters/usfm2osis.pl
index 41e02b3..b287f99 100644
--- a/modules/perlconverters/usfm2osis.pl
+++ b/modules/perlconverters/usfm2osis.pl
@@ -194,6 +194,27 @@ foreach $file (@files) {
}
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,11 +233,6 @@ foreach $file (@files) {
#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])/&amp;/g;