diff options
Diffstat (limited to 'lib/sisu/v6/ao_numbering.rb')
-rw-r--r-- | lib/sisu/v6/ao_numbering.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb index ffafbf9c..5b2137e7 100644 --- a/lib/sisu/v6/ao_numbering.rb +++ b/lib/sisu/v6/ao_numbering.rb @@ -67,6 +67,7 @@ module SiSU_AO_Numbering def initialize(md,data) @md,@data=md,data @obj=@type=@ocn=@lv=@name=@index=@comment=nil + @chosen_seg_names=[] end def number_of_segments? if @@segments_count==0 @@ -323,16 +324,23 @@ module SiSU_AO_Numbering possible_seg_name=possible_seg_name. gsub(/\.$/,'') end - if possible_seg_name =~/^[0-9]+$/m \ + chosen_seg_name=if possible_seg_name =~/^[0-9]+$/m \ and possible_seg_name.to_i <= heading_num_is.to_i prefix + leading_zeros_fixed_width_number(possible_seg_name) - elsif possible_seg_name =~/^[\d.,:-]+$/m + elsif possible_seg_name =~/^[0-9][\d.,:-]*$/m possible_seg_name=possible_seg_name. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') prefix + possible_seg_name else prefix + possible_seg_name.to_s end + @chosen_seg_names << chosen_seg_name + if @chosen_seg_names.compact.uniq.length == @chosen_seg_names.compact.length #checks that all auto given seg names are unique + chosen_seg_name + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark("duplicated auto segment name: #{chosen_seg_name}; manually name level 1 segments '1~given_name'") + exit + end end def name_para_seg_filename(data) #segment naming, remaining # paragraph name/numbering rules @@ -369,7 +377,7 @@ module SiSU_AO_Numbering @md.set_heading_seg=true end if dob.name !~/^\S+/ \ - 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 + and dob.obj =~/^\s*(?:\S+\s+)?([0-9][0-9.,:-]*)/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,:extract) |