diff options
author | Ralph Amissah <ralph@amissah.com> | 2010-05-03 19:14:10 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2010-05-03 19:14:10 -0400 |
commit | 65124198251d6e0ac59294f76c30644ad4fac6d5 (patch) | |
tree | dc50da8382c66172f740cd233517c7f7243be23e /lib/sisu/v2/dal_numbering.rb | |
parent | debian/changelog (2.3.1-1) (diff) | |
parent | update: changelog, version (2.3.2) (diff) |
Merge branch 'upstream' into debian/sid
Diffstat (limited to 'lib/sisu/v2/dal_numbering.rb')
-rw-r--r-- | lib/sisu/v2/dal_numbering.rb | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/sisu/v2/dal_numbering.rb b/lib/sisu/v2/dal_numbering.rb index ea68fd22..c8460ced 100644 --- a/lib/sisu/v2/dal_numbering.rb +++ b/lib/sisu/v2/dal_numbering.rb @@ -89,18 +89,20 @@ module SiSU_numbering @tuned_file=@tuned_file.flatten end def number_sub_heading(dob,num,title_no) - 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 - end - if @md.toc_lev_limit \ - and @md.toc_lev_limit < num - dob.obj.gsub!(/^/,'!_ ') #bold line, watch + 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} ") + 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 + end + if @md.toc_lev_limit \ + and @md.toc_lev_limit < num + dob.obj.gsub!(/^/,'!_ ') #bold line, watch + end end dob end @@ -134,6 +136,7 @@ module SiSU_numbering end t_not=0 data.compact! + chapter_number_counter=0 data.each do |dob| #@md.seg_names << [additions to segment names] title_no=nil dob=SiSU_document_structure_extract::Structure.new(@md,dob).structure_markup #must happen earlier, node info etc. require @@ -141,6 +144,12 @@ module SiSU_numbering and dob.autonum_ \ and defined? @md.make.num_top \ and @md.make.num_top !~/^$/ + 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") + end if dob.ln==no1 @subnumber=1 @subnumber=0 if dob.ln==no1 |