aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-07-07 01:21:51 -0400
committerRalph Amissah <ralph@amissah.com>2014-07-07 01:36:30 -0400
commit0c80533993f1f8dfcb5a68e75ca49cd216dc68bd (patch)
tree2df027c3bf733551884e363ce258cbc70182feac /lib/sisu/v5
parentbin/sisu, processing dir related (diff)
v5 v6: ao, auto seg naming, adjustments
* re: seg numbering, fixed width, leading zeros (introduced: 5.4.3 / 6.0.9)
Diffstat (limited to 'lib/sisu/v5')
-rw-r--r--lib/sisu/v5/ao_numbering.rb23
-rw-r--r--lib/sisu/v5/constants.rb3
2 files changed, 15 insertions, 11 deletions
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_',