diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-07-11 00:05:23 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-07-11 00:05:23 -0400 |
commit | 561b66275f186fcf8f3ed6e697e560f28354d38c (patch) | |
tree | 179f038a7a7299b8efe8f8529b06e1c0d4bd529e /lib | |
parent | v5 v6: ao_numbering, auto name segment, extract "number" from heading, fix (diff) |
v5 v6: ao_numbering, check that all auto given number based seg names are unique
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v5/ao_numbering.rb | 10 | ||||
-rw-r--r-- | lib/sisu/v6/ao_numbering.rb | 10 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb index d213ca4d..dc6ec4dd 100644 --- a/lib/sisu/v5/ao_numbering.rb +++ b/lib/sisu/v5/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,7 +324,7 @@ 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 =~/^[0-9][\d.,:-]*$/m @@ -333,6 +334,13 @@ module SiSU_AO_Numbering 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 diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb index ef85bbd6..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,7 +324,7 @@ 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 =~/^[0-9][\d.,:-]*$/m @@ -333,6 +334,13 @@ module SiSU_AO_Numbering 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 |