From 0c80533993f1f8dfcb5a68e75ca49cd216dc68bd Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 7 Jul 2014 01:21:51 -0400 Subject: v5 v6: ao, auto seg naming, adjustments * re: seg numbering, fixed width, leading zeros (introduced: 5.4.3 / 6.0.9) --- data/doc/sisu/CHANGELOG_v5 | 8 ++++++-- data/doc/sisu/CHANGELOG_v6 | 8 ++++++-- lib/sisu/v5/ao_numbering.rb | 23 +++++++++++++---------- lib/sisu/v5/constants.rb | 3 ++- lib/sisu/v6/ao_numbering.rb | 23 +++++++++++++---------- lib/sisu/v6/constants.rb | 3 ++- 6 files changed, 42 insertions(+), 26 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 3a994672..eba3b432 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -50,6 +50,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.5.orig.tar.xz sisu --html -v --glob live-manual * some cosmetic long line breaking +* ao, auto seg naming, adjustments, + re: seg numbering, fixed width, leading zeros (introduced: 5.4.3 / 6.0.9) + %% 5.4.4.orig.tar.xz (2014-07-04:26/5) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/sisu_5.4.4 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/debian/sisu_5.4.4-1 @@ -57,8 +60,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.4.orig.tar.xz sisu_5.4.4.orig.tar.xz sisu_5.4.4-1.dsc -* ao, fix, re seg numbering, fixed width, leading zeros (introduced in 5.4.3) - provisional fix (check related issues against 5.4.2) +* ao, fix, re seg numbering, fixed width, leading zeros + (introduced: 5.4.3 / 6.0.9) + provisional fix (check related issues against 5.4.2 / 6.0.8) %% 5.4.3.orig.tar.xz (2014-07-01:26/2) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/sisu_5.4.3 diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index ff82853d..eef28547 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -40,6 +40,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.11.orig.tar.xz sisu --html -v --glob live-manual * some cosmetic long line breaking +* ao, auto seg naming, adjustments, + re: seg numbering, fixed width, leading zeros (introduced: 5.4.3 / 6.0.9) + %% 6.0.10.orig.tar.xz (2014-07-04:26/5) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/sisu_6.0.10 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/debian/sisu_6.0.10-1 @@ -47,8 +50,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.10.orig.tar.xz sisu_6.0.10.orig.tar.xz sisu_6.0.10-1.dsc -* ao, fix, re seg numbering, fixed width, leading zeros (introduced in 6.0.9) - provisional fix (check related issues against 5.4.2) +* ao, fix, re seg numbering, fixed width, leading zeros + (introduced: 5.4.3 / 6.0.9) + provisional fix (check related issues against 5.4.2 / 6.0.8) %% 6.0.9.orig.tar.xz (2014-07-01:26/2) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/sisu_6.0.9 diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb index 9fbaaab5..278ea514 100644 --- a/lib/sisu/v5/ao_numbering.rb +++ b/lib/sisu/v5/ao_numbering.rb @@ -308,27 +308,30 @@ module SiSU_AO_Numbering zeros_fixed_width=number_of_segments?.to_s.length zero_width=(zeros_fixed_width - nl) zero_width == 0 \ - ? Mx[:auto_seg_prefix] + - possible_seg_name.to_s - : Mx[:auto_seg_prefix] + - zero*zero_width + + ? possible_seg_name.to_s + : zero*zero_width + possible_seg_name.to_s end end - def auto_seg_name(possible_seg_name,heading_num_is) + def auto_seg_name(possible_seg_name,heading_num_is,type) + prefix=case type + when :auto then Mx[:segname_prefix_auto_num_provide] + when :extract then Mx[:segname_prefix_auto_num_extract] + else '_' #should not occur + end if possible_seg_name =~/^[0-9]+?\.$/m #!~/[.,:-]+/ possible_seg_name=possible_seg_name. gsub(/\.$/,'') end if possible_seg_name =~/^[0-9]+$/m \ and possible_seg_name.to_i <= heading_num_is.to_i - leading_zeros_fixed_width_number(possible_seg_name) + prefix + leading_zeros_fixed_width_number(possible_seg_name) elsif possible_seg_name =~/^[\d.,:-]+$/m possible_seg_name=possible_seg_name. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') - #Mx[:auto_seg_prefix] + possible_seg_name - else possible_seg_name.to_s + prefix + possible_seg_name + else prefix + possible_seg_name.to_s end end def name_para_seg_filename(data) #segment naming, remaining @@ -369,7 +372,7 @@ module SiSU_AO_Numbering and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name possible_seg_name=$1 possible_seg_name= - auto_seg_name(possible_seg_name,heading_num_is) + auto_seg_name(possible_seg_name,heading_num_is,:extract) possible_seg_name=possible_seg_name. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') @@ -394,7 +397,7 @@ module SiSU_AO_Numbering if dob.ln==4 \ and not dob.name #if still no segment name, provide a numerical one possible_seg_name= - auto_seg_name(art_filename_auto,heading_num_is) + auto_seg_name(art_filename_auto,heading_num_is,:auto) if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(possible_seg_name) dob.name=possible_seg_name diff --git a/lib/sisu/v5/constants.rb b/lib/sisu/v5/constants.rb index eb252fda..05678b32 100644 --- a/lib/sisu/v5/constants.rb +++ b/lib/sisu/v5/constants.rb @@ -104,7 +104,8 @@ Xx={ html_relative1: '※', } Mx={ - auto_seg_prefix: 's', + segname_prefix_auto_num_extract: 's', + segname_prefix_auto_num_provide: 's_', ocn_id_char: 'o', note: 'note_', note_ref: 'noteref_', diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb index 755db795..ffafbf9c 100644 --- a/lib/sisu/v6/ao_numbering.rb +++ b/lib/sisu/v6/ao_numbering.rb @@ -308,27 +308,30 @@ module SiSU_AO_Numbering zeros_fixed_width=number_of_segments?.to_s.length zero_width=(zeros_fixed_width - nl) zero_width == 0 \ - ? Mx[:auto_seg_prefix] + - possible_seg_name.to_s - : Mx[:auto_seg_prefix] + - zero*zero_width + + ? possible_seg_name.to_s + : zero*zero_width + possible_seg_name.to_s end end - def auto_seg_name(possible_seg_name,heading_num_is) + def auto_seg_name(possible_seg_name,heading_num_is,type) + prefix=case type + when :auto then Mx[:segname_prefix_auto_num_provide] + when :extract then Mx[:segname_prefix_auto_num_extract] + else '_' #should not occur + end if possible_seg_name =~/^[0-9]+?\.$/m #!~/[.,:-]+/ possible_seg_name=possible_seg_name. gsub(/\.$/,'') end if possible_seg_name =~/^[0-9]+$/m \ and possible_seg_name.to_i <= heading_num_is.to_i - leading_zeros_fixed_width_number(possible_seg_name) + prefix + leading_zeros_fixed_width_number(possible_seg_name) elsif possible_seg_name =~/^[\d.,:-]+$/m possible_seg_name=possible_seg_name. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') - #Mx[:auto_seg_prefix] + possible_seg_name - else possible_seg_name.to_s + prefix + possible_seg_name + else prefix + possible_seg_name.to_s end end def name_para_seg_filename(data) #segment naming, remaining @@ -369,7 +372,7 @@ module SiSU_AO_Numbering and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name possible_seg_name=$1 possible_seg_name= - auto_seg_name(possible_seg_name,heading_num_is) + auto_seg_name(possible_seg_name,heading_num_is,:extract) possible_seg_name=possible_seg_name. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') @@ -394,7 +397,7 @@ module SiSU_AO_Numbering if dob.ln==4 \ and not dob.name #if still no segment name, provide a numerical one possible_seg_name= - auto_seg_name(art_filename_auto,heading_num_is) + auto_seg_name(art_filename_auto,heading_num_is,:auto) if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(possible_seg_name) dob.name=possible_seg_name diff --git a/lib/sisu/v6/constants.rb b/lib/sisu/v6/constants.rb index d25478d1..53ed226a 100644 --- a/lib/sisu/v6/constants.rb +++ b/lib/sisu/v6/constants.rb @@ -104,7 +104,8 @@ Xx={ html_relative1: '※', } Mx={ - auto_seg_prefix: 's', + segname_prefix_auto_num_extract: 's', + segname_prefix_auto_num_provide: 's_', ocn_id_char: 'o', note: 'note_', note_ref: 'noteref_', -- cgit v1.2.3