From bb1e2142668528a5e584b6b493c00f23aa59c637 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 12 Sep 2008 01:46:25 -0400 Subject: dal_idx: strip before sort; fix bug where first lev is range --- lib/sisu/v0/dal_idx.rb | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb index 74ec0d15..f8eb5e45 100644 --- a/lib/sisu/v0/dal_idx.rb +++ b/lib/sisu/v0/dal_idx.rb @@ -104,17 +104,6 @@ module SiSU_book_index end [tuned_file,sisu_markup_idx,html_idx] end - def output_html_idx(html_idx) - if @md.book_index - path="#{@env.path.output}/#{@md.fnb}" - Dir.mkdir(path) unless FileTest.directory?(path) - html_index_file=File.new("#{path}/#{@md.fn[:book_index]}",'w') - puts "#{path}/#{@md.fn[:book_index]}" - #html_file(the_idx) - html_idx.each {|x| html_index_file << x } - html_index_file.close - end - end def construct_idx_array(idx_array) idx_lst=[] idx_array.each do |idx| @@ -123,6 +112,7 @@ module SiSU_book_index g=idx_list.scan(/[^;]+/) idxl=[] g.each do |i| + i.strip! idxl << { :rough_idx => i, :ocn => ocn, :seg => seg } end idxl @@ -136,6 +126,7 @@ module SiSU_book_index @the_idx={} idx_array.each do |idx| idx_lst=idx[:rough_idx].scan(/[^|:]+/) + idx_lst[0].strip! if idx_lst[0] =~/.+?\+\d+/ use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2] else use=idx_lst[0] @@ -144,7 +135,7 @@ module SiSU_book_index idx_lst.each do |i| i.strip! i,r=/(.+?)\+(\d+)/.match(i)[1,2] if i =~/.+?\+\d+/ - x=if idx_lst.length == 1 or idx_lst[0] == i + x=if idx_lst.length == 1 or idx_lst[0].gsub(/\+\d+/,'') == i @the_idx[use]['a1']=[] unless @the_idx[use]['a1'] and defined? @the_idx[use]['a1'] x=if r @the_idx[use]['a1'] << { :ocn => idx[:ocn], :range => "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", :seg => idx[:seg] } @@ -278,6 +269,17 @@ module SiSU_book_index end end end + def output_html_idx(html_idx) + if @md.book_index + path="#{@env.path.output}/#{@md.fnb}" + Dir.mkdir(path) unless FileTest.directory?(path) + html_index_file=File.new("#{path}/#{@md.fn[:book_index]}",'w') + puts "#{path}/#{@md.fn[:book_index]}" + #html_file(the_idx) + html_idx.each {|x| html_index_file << x } + html_index_file.close + end + end def clean_and_insert_index(data,sisu_markup_idx) tuned_file=[] data.each do |para| -- cgit v1.2.3