# encoding: utf-8
=begin
* Name: SiSU
* Description: a framework for document structuring, publishing and search
* Author: Ralph Amissah
* Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah,
All Rights Reserved.
* License: GPL 3 or later:
SiSU, a framework for document structuring, publishing and search
Copyright (C) Ralph Amissah
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see '
idx[:xhtml] << ' '
alph.each do |x|
if x =~/[0-9]/
idx[:html] << ''
idx[:xhtml] << ''
else
idx[:html] << %{#{x},#{$ep[:hsp]}}
idx[:xhtml] << %{#{x},#{$ep[:hsp]}}
end
end
idx[:html] << '
0 - 9
} the_idx.each do |i| i.each do |x| if x.is_a?(String) f=/^(\S)/.match(x)[1] if letter < f while letter < f if alph.length > 0 letter=alph.shift idx[:html] << %{\n} 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]} } aname=x.gsub(/\s+/,'_') idx[:html] << %{\n#{x}, } c=clean_xml(x.dup) 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) @r=idx[:xhtml].index(idx[:xhtml].last) print "\n" + x + ', ' if @md.opt.act[:verbose_plus][:set]==:on elsif x.is_a?(Array) p 'array error? -->' print x elsif x.is_a?(Hash) 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##{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##{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 end idx[:html][@q]=idx[:html][@q] + '
' idx[:xhtml][@r]=idx[:xhtml][@r] + '' end 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}, } c=clean_xml(k.dup) 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##{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##{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 end idx[:html][@q]=idx[:html][@q] + '
' idx[:xhtml][@r]=idx[:xhtml][@r] + '' end end end @x +=1 end end end print "\n" if @md.opt.act[:verbose_plus][:set]==:on idx end def screen_print(the_idx) the_idx.each do |i| i.each do |x| if x.is_a?(String) print "\n" + x + ', ' elsif x.is_a?(Array) p 'array error? -->' print x elsif x.is_a?(Hash) if x['node_0_terms'].is_a?(Array) x['node_0_terms'].each do |a| if a[:range] print a[:range] + ', ' elsif a[:ocn] print a[:ocn] + ', ' else p 'error' end end end if x['node_1_subterms'] x['node_1_subterms'].sort.each do |k,y| if k !~/node_0_terms/ print "\n\t" + k + ', ' y.each do |z| if z[:range] print z[:range] + ', ' elsif z[:ocn] print z[:ocn] + ', ' else p 'error' end end end end end end end end end def output_idx(idx) if @md.book_idx path="#{@env.path.output}/#{@md.fnb}" Dir.mkdir(path) unless FileTest.directory?(path) puts "#{path}/#{@md.fn[:book_idx_html]} #{__FILE__}::#{__LINE__}" html_index_file=File.new("#{path}/#{@md.fn[:book_idx_html]}",'w') idx[:html].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 |dob| tuned_file << dob if dob.obj =~/#{Mx[:br_endnotes]}/ \ and sisu_markup_idx sisu_markup_idx.each do |idx| tuned_file << idx end end end tuned_file end def clean_index(data) #check on use of dob tuned_file=[] data.each do |para| para=para.gsub(/\n*#{@rgx_idx}/m,'') tuned_file << para end tuned_file end end end __END__