diff options
Diffstat (limited to 'lib/sisu/v6/ao_numbering.rb')
-rw-r--r-- | lib/sisu/v6/ao_numbering.rb | 23 |
1 files changed, 13 insertions, 10 deletions
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 |