From 9347018753e818b49980651df3b77352c5f3792f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:45:40 -0400 Subject: v5 v6: ao, code cosmetic rearrangement --- lib/sisu/v6/ao_idx.rb | 194 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 146 insertions(+), 48 deletions(-) (limited to 'lib/sisu/v6/ao_idx.rb') diff --git a/lib/sisu/v6/ao_idx.rb b/lib/sisu/v6/ao_idx.rb index eaaf7a90..7a4b1f03 100644 --- a/lib/sisu/v6/ao_idx.rb +++ b/lib/sisu/v6/ao_idx.rb @@ -67,14 +67,26 @@ module SiSU_AO_BookIndex @rgx_idx=/#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/ @rgx_idx_ocn_seg=/(.+?)~(\d+)~(\S+)/ @rgx_idx_ocn=/(.+?)~(\d+)/ - @ocn_html_identifier=SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier + @ocn_html_identifier= + SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier @env ||=SiSU_Env::InfoEnv.new(@md.fns) end def indexing_song data=@data - data,sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx=extract_book_index(data) - data=clean_and_insert_index(data,sisu_markup_idx_rel_html_seg) - [data,sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx] + data, + sisu_markup_idx_rel, + sisu_markup_idx_rel_html_seg, + html_idx,xhtml_idx= + extract_book_index(data) + data= + clean_and_insert_index(data,sisu_markup_idx_rel_html_seg) + [ + data, + sisu_markup_idx_rel, + sisu_markup_idx_rel_html_seg, + html_idx, + xhtml_idx, + ] end def extract_book_index(data) tuned_file=[] @@ -93,13 +105,25 @@ module SiSU_AO_BookIndex end if idx_array.length > 0 the_idx=construct_book_index(idx_array) - sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx=nil,nil,nil,nil if @md.book_idx idx=index(the_idx) - sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx=idx[:sst_rel],idx[:sst_rel_html_seg],idx[:html],idx[:xhtml] + sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx, xhtml_idx= + idx[:sst_rel], idx[:sst_rel_html_seg], idx[:html],idx[:xhtml] + else + sisu_markup_idx_rel= + sisu_markup_idx_rel_html_seg= + html_idx= + xhtml_idx= + nil end end - [tuned_file,sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx] + [ + tuned_file, + sisu_markup_idx_rel, + sisu_markup_idx_rel_html_seg, + html_idx, + xhtml_idx, + ] end def construct_book_index(idx_array) the_idx={} @@ -108,8 +132,12 @@ module SiSU_AO_BookIndex location=(term_info[:plus].to_i > 0) \ ? (%{#{idx[:ocn]}-#{idx[:ocn].to_i + term_info[:plus].to_i}}) : idx[:ocn].to_s - the_idx[term]={} unless the_idx[term] and defined? the_idx[term] - the_idx[term]['node_0_terms']=[] unless the_idx[term]['node_0_terms'] and defined? the_idx[term]['node_0_terms'] + the_idx[term]={} \ + unless the_idx[term] \ + and defined? the_idx[term] + the_idx[term]['node_0_terms']=[] \ + unless the_idx[term]['node_0_terms'] \ + and defined? the_idx[term]['node_0_terms'] the_idx[term]['node_0_terms'] << { ocn: idx[:ocn], range: location, seg: idx[:seg] } if term_info[:sub].is_a?(Array) \ and term_info[:sub].length > 0 @@ -118,11 +146,20 @@ module SiSU_AO_BookIndex location=(subterm_info[:plus].to_i > 0) \ ? (%{#{idx[:ocn]}-#{idx[:ocn].to_i + subterm_info[:plus].to_i}}) : idx[:ocn].to_s - the_idx[term]={} unless the_idx[term] and defined? the_idx[term] - the_idx[term]['node_0_terms']=[] unless the_idx[term]['node_0_terms'] and defined? the_idx[term]['node_0_terms'] - the_idx[term]['node_1_subterms']={} unless the_idx[term]['node_1_subterms'] and defined? the_idx[term]['node_1_subterms'] - the_idx[term]['node_1_subterms'][subterm]=[] unless the_idx[term]['node_1_subterms'][subterm] and defined? the_idx[term]['node_1_subterms'][subterm] - the_idx[term]['node_1_subterms'][subterm] << { ocn: idx[:ocn], range: location, seg: idx[:seg] } + the_idx[term]={} \ + unless the_idx[term] \ + and defined? the_idx[term] + the_idx[term]['node_0_terms']=[] \ + unless the_idx[term]['node_0_terms']\ + and defined? the_idx[term]['node_0_terms'] + the_idx[term]['node_1_subterms']={} \ + unless the_idx[term]['node_1_subterms'] \ + and defined? the_idx[term]['node_1_subterms'] + the_idx[term]['node_1_subterms'][subterm]=[] \ + unless the_idx[term]['node_1_subterms'][subterm] \ + and defined? the_idx[term]['node_1_subterms'][subterm] + the_idx[term]['node_1_subterms'][subterm] << + { ocn: idx[:ocn], range: location, seg: idx[:seg] } end end end @@ -138,16 +175,27 @@ module SiSU_AO_BookIndex def index(the_idx) @x=1 idx={} - idx[:sst_rel_html_seg],idx[:sst_rel],idx[:html],idx[:xhtml]=[],[],[],[] - h={obj: Mx[:br_page]} + idx[:sst_rel_html_seg],idx[:sst_rel],idx[:html],idx[:xhtml]= + [], [], [], [] + h={ + obj: Mx[:br_page] + } o=SiSU_AO_DocumentStructure::ObjectLayout.new.break(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o - h={lv: '1', name: 'index', obj: "Index"} + h={ + lv: '1', + name: 'index', + obj: "Index" + } o=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o - h={lv: '4', name: 'idx', obj: " [Index] #{Mx[:pa_non_object_dummy_heading]}"} + h={ + lv: '4', + name: 'idx', + obj: " [Index] #{Mx[:pa_non_object_dummy_heading]}" + } o=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o @@ -159,15 +207,19 @@ module SiSU_AO_BookIndex idx[:html] << '' idx[:xhtml] << '' else - idx[:html] << %{#{x},#{$ep[:hsp]}} - idx[:xhtml] << %{#{x},#{$ep[:hsp]}} + idx[:html] << + %{#{x},#{$ep[:hsp]}} + idx[:xhtml] << + %{#{x},#{$ep[:hsp]}} end end idx[:html] << '

' idx[:xhtml] << '

' letter=alph.shift - idx[:html] << %{\n

} - idx[:xhtml] << %{\n

0 - 9

} + idx[:html] << + %{\n

} + idx[:xhtml] << + %{\n

0 - 9

} the_idx.each do |i| i.each do |x| if x.is_a?(String) @@ -176,18 +228,24 @@ module SiSU_AO_BookIndex while letter < f if alph.length > 0 letter=alph.shift - idx[:html] << %{\n

#{letter}

} - idx[:xhtml] << %{\n

#{letter}

} + idx[:html] << + %{\n

#{letter}

} + idx[:xhtml] << + %{\n

#{letter}

} else break end end end - idx[:sst_rel_html_seg] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } - idx[:sst_rel] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } + idx[:sst_rel_html_seg] << + %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } + idx[:sst_rel] << + %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } aname=x.gsub(/\s+/,'_') - idx[:html] << %{\n

#{x}, } + idx[:html] << + %{\n

#{x}, } c=clean_xml(x.dup) - idx[:xhtml] << %{\n

#{c}, } + idx[:xhtml] << + %{\n

#{c}, } @o=idx[:sst_rel_html_seg].index(idx[:sst_rel_html_seg].last) @t=idx[:sst_rel].index(idx[:sst_rel].last) @q=idx[:html].index(idx[:html].last) @@ -200,16 +258,32 @@ module SiSU_AO_BookIndex if x['node_0_terms'].is_a?(Array) x['node_0_terms'].each do |a| if a[:range] - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]=idx[:html][@q] + %{#{a[:range]}, } - idx[:xhtml][@q]=idx[:xhtml][@q] + %{#{a[:range]}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{a[:range]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{a[:range]}, } print a[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on elsif a[:ocn] - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]=idx[:html][@q] + %{#{a[:ocn]}, } - idx[:xhtml][@q]=idx[:xhtml][@q] + %{#{a[:ocn]}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{a[:ocn]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{a[:ocn]}, } print a[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on else p 'error' end @@ -220,24 +294,48 @@ module SiSU_AO_BookIndex if x['node_1_subterms'] x['node_1_subterms'].sort.each do |k,y| if k !~/node_0_terms/ - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{k}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{k}, } - idx[:html][@q]=idx[:html][@q] + %{\n

#{k}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{k}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{k}, } + idx[:html][@q]= + idx[:html][@q] + + %{\n

#{k}, } c=clean_xml(k.dup) - idx[:xhtml][@r]=idx[:xhtml][@r] + %{\n

#{c}, } + idx[:xhtml][@r]= + idx[:xhtml][@r] + + %{\n

#{c}, } print "\n\t" + k + ', ' if @md.opt.act[:verbose_plus][:set]==:on y.each do |z| if z[:range] - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]=idx[:html][@q] + %{#{z[:range]}, } - idx[:xhtml][@q]=idx[:xhtml][@q] + %{#{z[:range]}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{z[:range]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{z[:range]}, } print z[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on elsif z[:ocn] - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]=idx[:html][@q] + %{#{z[:ocn]}, } - idx[:xhtml][@q]=idx[:xhtml][@q] + %{#{z[:ocn]}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{z[:ocn]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{z[:ocn]}, } print z[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on else p 'error' end -- cgit v1.2.3