aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-07-15 18:35:37 -0400
committerRalph Amissah <ralph@amissah.com>2014-07-15 18:35:37 -0400
commit03c2846913b0abbbd8f8571ba45e948b00564bdb (patch)
tree2025ecf4a7d5737153bafc817c29faae470a396b
parentv5 v6: sysenv, general, base_markup_dir_stub (replace pwd_stub) (diff)
v5 v6: ao_numbering, auto name segment, extract "number" from heading, refine
-rw-r--r--data/doc/sisu/CHANGELOG_v52
-rw-r--r--data/doc/sisu/CHANGELOG_v62
-rw-r--r--lib/sisu/v5/ao_numbering.rb40
-rw-r--r--lib/sisu/v6/ao_numbering.rb40
4 files changed, 60 insertions, 24 deletions
diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5
index 20893629..4b1e3fef 100644
--- a/data/doc/sisu/CHANGELOG_v5
+++ b/data/doc/sisu/CHANGELOG_v5
@@ -42,6 +42,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.5.1.orig.tar.xz
* sysenv, general, base_markup_dir_stub (replace pwd_stub)
+* ao_numbering, auto name segment, extract "number" from heading, refine
+
%% 5.5.0.orig.tar.xz (2014-07-11:27/5)
http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/sisu_5.5.0
http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/debian/sisu_5.5.0-1
diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6
index e01ea795..a3a11127 100644
--- a/data/doc/sisu/CHANGELOG_v6
+++ b/data/doc/sisu/CHANGELOG_v6
@@ -32,6 +32,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.1.1.orig.tar.xz
* sysenv, general, base_markup_dir_stub (replace pwd_stub)
+* ao_numbering, auto name segment, extract "number" from heading, refine
+
%% 6.1.0.orig.tar.xz (2014-07-11:27/5)
http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/sisu_6.1.0
http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/debian/sisu_6.1.0-1
diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb
index dc6ec4dd..a8304fa3 100644
--- a/lib/sisu/v5/ao_numbering.rb
+++ b/lib/sisu/v5/ao_numbering.rb
@@ -301,7 +301,7 @@ module SiSU_AO_Numbering
@tuned_file=@tuned_file.flatten
end
def leading_zeros_fixed_width_number(possible_seg_name)
- if possible_seg_name =~/^([0-9]+?\.|[0-9]+)$/m #!~/[.,:-]+/
+ if possible_seg_name =~/^([0-9]+?\.|[0-9]+)$/m #!~/[.,:-]+/
possible_seg_name=possible_seg_name.
gsub(/\.$/,'')
nl=possible_seg_name.to_s.length
@@ -314,31 +314,47 @@ module SiSU_AO_Numbering
possible_seg_name.to_s
end
end
- def auto_seg_name(possible_seg_name,heading_num_is,type)
+ def auto_seg_name(possible_seg_name,heading_num_is,lv,type)
prefix=case type
- when :auto then Mx[:segname_prefix_auto_num_provide]
+ when :auto then Mx[:segname_prefix_auto_num_provide]
when :extract then Mx[:segname_prefix_auto_num_extract]
- else '_' #should not occur
+ else '_'*lv.to_i #should not occur
end
- if possible_seg_name =~/^[0-9]+?\.$/m #!~/[.,:-]+/
+ if possible_seg_name =~/^[0-9]+?\.$/m #!~/[.,:-]+/
possible_seg_name=possible_seg_name.
gsub(/\.$/,'')
end
- chosen_seg_name=if possible_seg_name =~/^[0-9]+$/m \
- and possible_seg_name.to_i <= heading_num_is.to_i
+ chosen_seg_name=if possible_seg_name =~/^[0-9]+[.]?$/m \
+ and possible_seg_name.to_i <= heading_num_is.to_i \
+ and lv == '1'
prefix + leading_zeros_fixed_width_number(possible_seg_name)
- elsif possible_seg_name =~/^[0-9][\d.,:-]*$/m
+ elsif possible_seg_name =~/^[0-9]+[.,:-]*$/m \
+ and lv == '1'
possible_seg_name=possible_seg_name.
gsub(/(?:[:,-]|\W)/,'.').
gsub(/\.$/,'')
prefix + possible_seg_name
- else prefix + possible_seg_name.to_s
+ elsif possible_seg_name =~
+ /^[0-9]+[.,:-][0-9]+[.,:-]*$/m \
+ and lv == '2'
+ possible_seg_name=possible_seg_name.
+ gsub(/(?:[:,-]|\W)/,'.').
+ gsub(/\.$/,'')
+ prefix + possible_seg_name
+ elsif possible_seg_name =~
+ /^[0-9]+[.,:-][0-9]+[.,:-][0-9][\d.,:-]*$/m \
+ and lv == '3'
+ possible_seg_name=possible_seg_name.
+ gsub(/(?:[:,-]|\W)/,'.').
+ gsub(/\.$/,'')
+ prefix + possible_seg_name
+ else 'x'*lv.to_i + 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'")
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark("duplicated auto segment name: #{type} #{chosen_seg_name} - #{@chosen_seg_names}; manually name level 1 segments '1~given_name'")
exit
end
end
@@ -380,7 +396,7 @@ module SiSU_AO_Numbering
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)
+ auto_seg_name(possible_seg_name,heading_num_is,dob.lv,:extract)
possible_seg_name=possible_seg_name.
gsub(/(?:[:,-]|\W)/,'.').
gsub(/\.$/,'')
@@ -405,7 +421,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)
+ auto_seg_name(art_filename_auto,heading_num_is,dob.lv,: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/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb
index 5b2137e7..1c5c326e 100644
--- a/lib/sisu/v6/ao_numbering.rb
+++ b/lib/sisu/v6/ao_numbering.rb
@@ -301,7 +301,7 @@ module SiSU_AO_Numbering
@tuned_file=@tuned_file.flatten
end
def leading_zeros_fixed_width_number(possible_seg_name)
- if possible_seg_name =~/^([0-9]+?\.|[0-9]+)$/m #!~/[.,:-]+/
+ if possible_seg_name =~/^([0-9]+?\.|[0-9]+)$/m #!~/[.,:-]+/
possible_seg_name=possible_seg_name.
gsub(/\.$/,'')
nl=possible_seg_name.to_s.length
@@ -314,31 +314,47 @@ module SiSU_AO_Numbering
possible_seg_name.to_s
end
end
- def auto_seg_name(possible_seg_name,heading_num_is,type)
+ def auto_seg_name(possible_seg_name,heading_num_is,lv,type)
prefix=case type
- when :auto then Mx[:segname_prefix_auto_num_provide]
+ when :auto then Mx[:segname_prefix_auto_num_provide]
when :extract then Mx[:segname_prefix_auto_num_extract]
- else '_' #should not occur
+ else '_'*lv.to_i #should not occur
end
- if possible_seg_name =~/^[0-9]+?\.$/m #!~/[.,:-]+/
+ if possible_seg_name =~/^[0-9]+?\.$/m #!~/[.,:-]+/
possible_seg_name=possible_seg_name.
gsub(/\.$/,'')
end
- chosen_seg_name=if possible_seg_name =~/^[0-9]+$/m \
- and possible_seg_name.to_i <= heading_num_is.to_i
+ chosen_seg_name=if possible_seg_name =~/^[0-9]+[.]?$/m \
+ and possible_seg_name.to_i <= heading_num_is.to_i \
+ and lv == '1'
prefix + leading_zeros_fixed_width_number(possible_seg_name)
- elsif possible_seg_name =~/^[0-9][\d.,:-]*$/m
+ elsif possible_seg_name =~/^[0-9]+[.,:-]*$/m \
+ and lv == '1'
possible_seg_name=possible_seg_name.
gsub(/(?:[:,-]|\W)/,'.').
gsub(/\.$/,'')
prefix + possible_seg_name
- else prefix + possible_seg_name.to_s
+ elsif possible_seg_name =~
+ /^[0-9]+[.,:-][0-9]+[.,:-]*$/m \
+ and lv == '2'
+ possible_seg_name=possible_seg_name.
+ gsub(/(?:[:,-]|\W)/,'.').
+ gsub(/\.$/,'')
+ prefix + possible_seg_name
+ elsif possible_seg_name =~
+ /^[0-9]+[.,:-][0-9]+[.,:-][0-9][\d.,:-]*$/m \
+ and lv == '3'
+ possible_seg_name=possible_seg_name.
+ gsub(/(?:[:,-]|\W)/,'.').
+ gsub(/\.$/,'')
+ prefix + possible_seg_name
+ else 'x'*lv.to_i + 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'")
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark("duplicated auto segment name: #{type} #{chosen_seg_name} - #{@chosen_seg_names}; manually name level 1 segments '1~given_name'")
exit
end
end
@@ -380,7 +396,7 @@ module SiSU_AO_Numbering
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)
+ auto_seg_name(possible_seg_name,heading_num_is,dob.lv,:extract)
possible_seg_name=possible_seg_name.
gsub(/(?:[:,-]|\W)/,'.').
gsub(/\.$/,'')
@@ -405,7 +421,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)
+ auto_seg_name(art_filename_auto,heading_num_is,dob.lv,:auto)
if @md.seg_names.is_a?(Array) \
and not @md.seg_names.include?(possible_seg_name)
dob.name=possible_seg_name