From c11185f9e9c7b9acabb3a8a49dbc56d1a01c51b3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 28 Apr 2010 22:39:57 -0400 Subject: dal, markup, auto-level 1~ conversion of hash to number In cases where the line is interpreted as level 1~ (either by explicit 1~ tag or @make: :heading:) a hash (#) [octothorpe] will be auto-incremented, markup e.g. "1~ Chapter #: My Way". --- lib/sisu/v2/dal_numbering.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/sisu/v2/dal_numbering.rb b/lib/sisu/v2/dal_numbering.rb index ea68fd22..d1db1939 100644 --- a/lib/sisu/v2/dal_numbering.rb +++ b/lib/sisu/v2/dal_numbering.rb @@ -134,6 +134,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 +142,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 -- cgit v1.2.3