From 844f9270e3190ec55666d787cfc8c482997cfc06 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:47:13 -0400 Subject: v5 v6: ao, (param), book index, strip white spaces around terms * fix uppercase first character where spaces used --- data/doc/sisu/CHANGELOG_v5 | 2 ++ data/doc/sisu/CHANGELOG_v6 | 2 ++ lib/sisu/v5/ao_doc_str.rb | 7 ++++--- lib/sisu/v5/param.rb | 2 +- lib/sisu/v6/ao_doc_str.rb | 7 ++++--- lib/sisu/v6/param.rb | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index f4c824f5..7acd5140 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -40,6 +40,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.3.orig.tar.xz * ao, * code cosmetic rearrangement + * book index, strip white spaces around terms + (fix uppercase first character where spaces used) * code cosmetic rearrangement * ao*, param, hub, options, composite diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 81420f21..beada6ad 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -30,6 +30,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.9.orig.tar.xz * ao, * code cosmetic rearrangement + * book index, strip white spaces around terms + (fix uppercase first character where spaces used) * code cosmetic rearrangement * ao*, param, hub, options, composite diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index 9743f794..c3b65ee1 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -200,6 +200,7 @@ module SiSU_AO_DocumentStructureExtract idx_array_raw=idxraw.scan(/[^;]+/) idx_hash,idx_array,idx_lst={},[],[] idx_array_raw.each do |idx| + idx=idx.strip idx_lst=case idx when /\S+?\s*:/ idx_couplet_tmp=[] @@ -308,11 +309,11 @@ module SiSU_AO_DocumentStructureExtract and @@flag[:box]==:off \ and @@flag[:table]==:off unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any - idx=if t_o=~/^=\{(.+)\}\s*$\Z/m; m=$1 - m=m.split(/\n/).join(' '). + idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m; m=$1 + m=m.split(/[ ]*\n/).join(' '). gsub(/\s+([|:;])\s+/,'\1'). gsub(/\s+([+]\d+)\s+/,'\1') - t_o=t_o.gsub(/\n=\{.+\}\s*$\Z/m,'') + t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'') idx_array_and_hash=construct_idx_array_and_hash(m) idx_array_and_hash[:hash] else nil diff --git a/lib/sisu/v5/param.rb b/lib/sisu/v5/param.rb index d20a0129..b2e50d41 100644 --- a/lib/sisu/v5/param.rb +++ b/lib/sisu/v5/param.rb @@ -1167,7 +1167,7 @@ module SiSU_Param ).txt_grey if @opt.act[:verbose][:set]==:on end if not @book_idx \ - and para =~/^=\{(.+?)\}\s*$/ + and para =~/^=\{(.+?)\}[\s`]*\Z/m @book_idx=true end unless @code_flag diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 675bfc90..001b2aef 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -200,6 +200,7 @@ module SiSU_AO_DocumentStructureExtract idx_array_raw=idxraw.scan(/[^;]+/) idx_hash,idx_array,idx_lst={},[],[] idx_array_raw.each do |idx| + idx=idx.strip idx_lst=case idx when /\S+?\s*:/ idx_couplet_tmp=[] @@ -308,11 +309,11 @@ module SiSU_AO_DocumentStructureExtract and @@flag[:box]==:off \ and @@flag[:table]==:off unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any - idx=if t_o=~/^=\{(.+)\}\s*$\Z/m; m=$1 - m=m.split(/\n/).join(' '). + idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m; m=$1 + m=m.split(/[ ]*\n/).join(' '). gsub(/\s+([|:;])\s+/,'\1'). gsub(/\s+([+]\d+)\s+/,'\1') - t_o=t_o.gsub(/\n=\{.+\}\s*$\Z/m,'') + t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'') idx_array_and_hash=construct_idx_array_and_hash(m) idx_array_and_hash[:hash] else nil diff --git a/lib/sisu/v6/param.rb b/lib/sisu/v6/param.rb index 1e7ea9de..bacee802 100644 --- a/lib/sisu/v6/param.rb +++ b/lib/sisu/v6/param.rb @@ -1167,7 +1167,7 @@ module SiSU_Param ).txt_grey if @opt.act[:verbose][:set]==:on end if not @book_idx \ - and para =~/^=\{(.+?)\}\s*$/ + and para =~/^=\{(.+?)\}[\s`]*\Z/m @book_idx=true end unless @code_flag -- cgit v1.2.3