aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3dv/dal_numbering.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3dv/dal_numbering.rb')
-rw-r--r--lib/sisu/v3dv/dal_numbering.rb73
1 files changed, 36 insertions, 37 deletions
diff --git a/lib/sisu/v3dv/dal_numbering.rb b/lib/sisu/v3dv/dal_numbering.rb
index cf7d861a..332db4bf 100644
--- a/lib/sisu/v3dv/dal_numbering.rb
+++ b/lib/sisu/v3dv/dal_numbering.rb
@@ -77,12 +77,13 @@ module SiSU_DAL_Numbering
def number_plaintext_para(data)
@tuned_file=[]
data.each do |dob|
- if dob.of !~/(?:block|comment|layout)/ and dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX
- dob.obj.gsub!(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks
+ if dob.of !~/(?:block|comment|layout)/ \
+ and dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX
+ dob.obj=dob.obj.gsub(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks
end
unless dob.obj.class==Array
- dob.obj.gsub!(/^\s+/,'')
- dob.obj.gsub!(/\s$/,"\n")
+ dob.obj=dob.obj.gsub(/^\s+/,'').
+ gsub(/\s$/,"\n")
end
@tuned_file << dob
end
@@ -90,37 +91,35 @@ module SiSU_DAL_Numbering
end
def number_sub_heading(dob,num,title_no)
unless dob.obj =~/\d+\.|(?:chapter|article|section|clause)\s+\d+/i #name selection arbitrary, fix
- case dob.name
- when /-/; dob.obj.gsub!(/^/,"#{title_no} ")
- when /^#/; dob.obj.gsub!(/^/,"#{title_no} ")
- when /^[a-z_\.]+/
- dob.obj.gsub!(/^/,"#{title_no} ")
+ dob.obj=case dob.name
+ when /-/; dob.obj.gsub(/^/,"#{title_no} ")
+ when /^#/; dob.obj.gsub(/^/,"#{title_no} ")
+ when /^[a-z_\.]+/; dob.obj.gsub(/^/,"#{title_no} ")
else
dob.name=title_no if dob.name=~/^$/ #where title contains title number
- dob.obj.gsub!(/^/,"#{title_no} ") if title_no =~/\d+/ #main, where title number is to be provided #watch changed placement
+ dob.obj.gsub(/^/,"#{title_no} ") if title_no =~/\d+/ #main, where title number is to be provided #watch changed placement
end
if @md.toc_lev_limit \
and @md.toc_lev_limit < num
- dob.obj.gsub!(/^/,'!_ ') #bold line, watch
+ dob.obj=dob.obj.gsub(/^/,'!_ ') #bold line, watch
end
end
dob
end
def heading_tag_clean(heading_tag)
- heading_tag.gsub!(/[ ]+/,'_')
- heading_tag.gsub!(/["']/,'')
- heading_tag.gsub!(/[\/]/,'-')
- heading_tag.gsub!(/#{Mx[:fa_bold_o]}|#{Mx[:fa_bold_c]}/,'')
- heading_tag.gsub!(/#{Mx[:fa_italics_o]}|#{Mx[:fa_italics_c]}/,'')
- heading_tag.gsub!(/#{Mx[:fa_underscore_o]}|#{Mx[:fa_underscore_c]}/,'')
- heading_tag.gsub!(/#{Mx[:fa_cite_o]}|#{Mx[:fa_cite_c]}/,'')
- heading_tag.gsub!(/#{Mx[:fa_insert_o]}|#{Mx[:fa_insert_c]}/,'')
- heading_tag.gsub!(/#{Mx[:fa_strike_o]}|#{Mx[:fa_strike_c]}/,'')
- heading_tag.gsub!(/#{Mx[:fa_superscript_o]}|#{Mx[:fa_superscript_c]}/,'')
- heading_tag.gsub!(/#{Mx[:fa_subscript_o]}|#{Mx[:fa_subscript_c]}/,'')
- heading_tag.gsub!(/#{Mx[:fa_hilite_o]}|#{Mx[:fa_hilite_c]}/,'')
- heading_tag.gsub!(/#{Mx[:gl_bullet]}/,'')
- heading_tag
+ heading_tag=heading_tag.gsub(/[ ]+/,'_').
+ gsub(/["']/,'').
+ gsub(/[\/]/,'-').
+ gsub(/#{Mx[:fa_bold_o]}|#{Mx[:fa_bold_c]}/,'').
+ gsub(/#{Mx[:fa_italics_o]}|#{Mx[:fa_italics_c]}/,'').
+ gsub(/#{Mx[:fa_underscore_o]}|#{Mx[:fa_underscore_c]}/,'').
+ gsub(/#{Mx[:fa_cite_o]}|#{Mx[:fa_cite_c]}/,'').
+ gsub(/#{Mx[:fa_insert_o]}|#{Mx[:fa_insert_c]}/,'').
+ gsub(/#{Mx[:fa_strike_o]}|#{Mx[:fa_strike_c]}/,'').
+ gsub(/#{Mx[:fa_superscript_o]}|#{Mx[:fa_superscript_c]}/,'').
+ gsub(/#{Mx[:fa_subscript_o]}|#{Mx[:fa_subscript_c]}/,'').
+ gsub(/#{Mx[:fa_hilite_o]}|#{Mx[:fa_hilite_c]}/,'').
+ gsub(/#{Mx[:gl_bullet]}/,'')
end
def auto_number_heading_ie_title(data) #also does some segment naming
@tuned_file=[]
@@ -135,8 +134,8 @@ module SiSU_DAL_Numbering
no1=num_top; no2=(num_top + 1); no3=(num_top + 2); no4=(num_top + 3)
end
t_not=0
- data.compact!
chapter_number_counter=0
+ data=data.compact
data.each do |dob| #@md.seg_names << [additions to segment names]
title_no=nil
dob=SiSU_DAL_DocumentStructureExtract::Structure.new(@md,dob).structure_markup #must happen earlier, node info etc. require
@@ -147,8 +146,8 @@ module SiSU_DAL_Numbering
if dob.lv=='1' \
and dob.obj =~/^#\s|\s#(?:\s|$)/
chapter_number_counter +=1
- dob.obj.gsub!(/^#\s/,"#{chapter_number_counter} ")
- dob.obj.gsub!(/#([:,]?\s|[.]?$)/,"#{chapter_number_counter}\\1")
+ dob.obj=dob.obj.gsub(/^#\s/,"#{chapter_number_counter} ").
+ gsub(/#([:,]?\s|[.]?$)/,"#{chapter_number_counter}\\1")
end
if dob.ln==no1
@subnumber=1
@@ -168,15 +167,15 @@ module SiSU_DAL_Numbering
tag=dob.obj.gsub(/(Article|Clause|Section|Chapter)\s+/,"\\1_#{title_no}").downcase
tag=heading_tag_clean(tag)
dob.tags=[tag,dob.tags].flatten if tag !~/^\d+$/ #check whether will work across file types with stop signs
- (dob.obj =~/(Article|Clause|Section)\s+/) \
- ? (dob.obj.gsub!(/(Article|Clause|Section)\s+/,"\\1 #{title_no} "))
- : (dob.obj.gsub!(/^/,"#{title_no}. ")) #fix stop later
+ dob.obj=(dob.obj =~/(Article|Clause|Section)\s+/) \
+ ? (dob.obj.gsub(/(Article|Clause|Section)\s+/,"\\1 #{title_no} "))
+ : (dob.obj.gsub(/^/,"#{title_no}. ")) #fix stop later
end
if dob.ln !=no1 \
and dob.obj =~/^[\d.]+\s/ #fix -> if the title starts with a numbering scheme, do not auto-number, review
dob.name ="#{title_no}" if not dob.name
dob.tags=[title_no,dob.tags].flatten if title_no !~/^\d+$/ #check whether will work across file types with stop signs
- dob.obj.gsub!(/^/,"#{title_no}. ")
+ dob.obj=dob.obj.gsub(/^/,"#{title_no}. ")
end
@md.seg_names << title_no
end
@@ -184,7 +183,7 @@ module SiSU_DAL_Numbering
and dob.name!~/^[a-z_\.]+$/ \
and dob.obj !~/[A-Z]\.?\s/ #bug -> tmp fix, excludes A. B. C. lettering, but not roman numerals, is arbitrary, review required # not fixed, work on
dob.tags=[title_no,dob.tags].flatten if title_no !~/^\d+$/ #check whether will work across file types with stop signs
- dob.obj.gsub!(/^/i,"#{title_no}. ")
+ dob.obj=dob.obj.gsub(/^/i,"#{title_no}. ")
end
end
if dob.ln==no1 #watch because here you change dob.name
@@ -251,10 +250,10 @@ module SiSU_DAL_Numbering
letter_small=0
number_small=0 if dob.obj =~ /^#1/
number_small+=1
- dob.obj.gsub!(/^#[ 1]/,"#{number_small}. ") #change 2004
+ dob.obj=dob.obj.gsub(/^#[ 1]/,"#{number_small}. ")
end
if dob.obj =~/^_# /
- dob.obj.gsub!(/^_# /,"#{letter[letter_small]}. ") #change 2004
+ dob.obj=dob.obj.gsub(/^_# /,"#{letter[letter_small]}. ")
dob.indent='1'
letter_small+=1
end
@@ -298,8 +297,8 @@ module SiSU_DAL_Numbering
if dob.name !~/^\S+/ \
and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name
possible_seg_name=$1
- possible_seg_name.gsub!(/(?:[:,-]|\W)/,'.')
- possible_seg_name.gsub!(/\.$/,'')
+ possible_seg_name=possible_seg_name.gsub(/(?:[:,-]|\W)/,'.').
+ gsub(/\.$/,'')
if not @md.seg_names.nil? \
and not @md.seg_names.include?(possible_seg_name)
dob.name=possible_seg_name