From 291080c0495f59f031bf5c0de2482f1bc7df59f2 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 10 Sep 2008 21:24:31 -0400 Subject: primarily on book index where (markup) provided * book index, html, tex/pdf, xml * texpdf no ocn if ocn is 0 * odf, plaintext, if book index? remove ... do other outputs for which not relevant * concordance, better matches * constants, dal special character for hardspace changed as (ruby) regx bug in replacing it in xml, odd but move on Note: to fix html seg headers for endnotes and for index --- lib/sisu/v0/concordance.rb | 22 +++--- lib/sisu/v0/constants.rb | 2 +- lib/sisu/v0/dal.rb | 56 +++++++++++++-- lib/sisu/v0/dal_idx.rb | 157 ++++++++++++++++++++----------------------- lib/sisu/v0/dal_syntax.rb | 1 + lib/sisu/v0/html.rb | 3 - lib/sisu/v0/html_segments.rb | 86 ++++++++++++++---------- lib/sisu/v0/odf.rb | 1 + lib/sisu/v0/particulars.rb | 13 +++- lib/sisu/v0/plaintext.rb | 1 + lib/sisu/v0/shared_xml.rb | 4 +- lib/sisu/v0/sysenv.rb | 6 ++ lib/sisu/v0/texpdf.rb | 1 + 13 files changed, 211 insertions(+), 142 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index 485f3df5..fad91d14 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -121,8 +121,8 @@ WOK end def create head_banner=SiSU_HTML_Format::Head_toc.new(@md) -minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,@data).songsheet -toc='
' + minitoc.to_s + '
' + minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,@data).songsheet + toc='
' + minitoc.to_s + '
' < @@ -199,7 +199,8 @@ WOK @rxp_t3=Regexp.new('^T3') @rxp_excluded1=/(?:https?|file|ftp):\/\/\S+/ @rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+| |#{Mx[:br_endnotes]}|EOF|#{Mx[:br_eof]}|thumb_\S+|snap_\S+|_+|-+|[(]?(?:ii+|iv|vi+|ix|xi+|xiv|xv|xvi+|xix|xx)[).]?|\S+?_\S+|[\d_]+\w\S+|[\w\d]{1,2}|\d{1,3}\w?|#@dp|[0-9a-f]{16,64}|\d{2,3}x\d{2,3}|\S{0,2}sha\d|\S{0,3}\d{4}w\d\d|\b\w\d+|\d_all\b|e\.?g\.?)(?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})?$/mi #this regex causes and cures a stack dump in ruby 1.9 !!! - @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|#{Mx[:gr_o]}code#{Mx[:gr_o]}.+?#{Mx[:gr_o]}code-end#{Mx[:gr_o]}|<\S+?>|#{Mx[:id_o]}\S+?#{Mx[:id_c]}|\w+|[a-zA-Z]+}mi + @rgx_splitlist=%r{[—.,;:-]|#{Mx[:id_o]}\S+?#{Mx[:id_c]}}mi + @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|#{Mx[:gr_o]}code#{Mx[:gr_o]}.+?#{Mx[:gr_o]}code-end#{Mx[:gr_o]}|<\S+?>|\w+|[a-zA-Z]+}mi rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error end end @@ -223,13 +224,13 @@ WOK @sfx='.html' #used for hardlinks, previous setting @sfx='', web server takes care of suffix @word_location_seg=wordlocation.gsub(/(.+?)\#(\d+)/,"#{@md.fnl[:pre]}\\1#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}#\\2") unless wordlocation.nil? case @wordlocation - when @rxp_t1 - %{[H]#@show, } - when @rxp_t2 - %{[H]#@show, } - when @rxp_t3 - %{[H]#@show, } - else %{#@show, } + when @rxp_t1 + %{[H]#@show, } + when @rxp_t2 + %{[H]#@show, } + when @rxp_t3 + %{[H]#@show, } + else %{#@show, } end end def map_para @@ -243,6 +244,7 @@ WOK end if toy =~/\d+/ \ and toy !~/^0$/ + line=line.split(@rgx_splitlist).join(' ') #%take in word or other match for word in line.scan(@rgx_scanlist) #%take in word or other match #word.gsub!(@rxp_clean,'') word.gsub!(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}(?:http)?/,'') diff --git a/lib/sisu/v0/constants.rb b/lib/sisu/v0/constants.rb index 3f050df7..414732e1 100644 --- a/lib/sisu/v0/constants.rb +++ b/lib/sisu/v0/constants.rb @@ -91,7 +91,7 @@ Mx[:gl_bullet]= "#{Mx[:gl_o]}●#{Mx[:gl_c]}" Mx[:pa_non_object_dummy_heading]="#{Mx[:pa_o]}-##{Mx[:pa_c]}" #unnumbered paragraph, delete when not required [used in dummy headings, eg. for segmented html] (place marker at end of paragraph) Mx[:pa_non_object_no_heading]="#{Mx[:pa_o]}~##{Mx[:pa_c]}" #unnumbered paragraph (place marker at end of paragraph) Mx[:idx_o]='▢ '; Mx[:idx_c]='▢ ' # -Mx[:nbsp]= '▭ ' +Mx[:nbsp]= '░' #'▭ ' Mx[:br_line]= "#{Mx[:mk_o]}br#{Mx[:mk_c]}" Mx[:br_paragraph]= "#{Mx[:mk_o]}br#{Mx[:mk_c]}" Mx[:br_nl]= "#{Mx[:mk_o]}nl#{Mx[:mk_c]}" diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index a00d307b..c01c2d0a 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -87,13 +87,14 @@ module SiSU_DAL end end class Source 0 if idx_array.length > 0 - if @md.cmd.inspect =~/M/ - the_idx=construct_book_index(idx_array) - screen_print(the_idx) if @md.cmd.inspect =~/M/ - puts "\n---" - path="#{@env.path.output}/#{@md.fnb}" - @file_index_all=File.open("#{path}/#{@md.fn[:book_index]}",'w') - screen_html(the_idx) - @file_index_all.close - puts "\n---" - screen_sisu_markup(the_idx) + the_idx=construct_book_index(idx_array) + #screen_print(the_idx) if @md.cmd.inspect =~/V/ + sisu_markup_idx,html_idx=nil,nil + if @md.book_index + idx=index(the_idx) + output_html_idx(idx[:html]) + html_idx=idx[:html] + sisu_markup_idx=idx[:sst] end end - tuned_file + [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=[] @@ -163,11 +170,22 @@ module SiSU_book_index #p the_idx; p '-----' the_idx end - def screen_print(the_idx) + def index(the_idx) + @x=1 + @idx={} + @idx[:sst],@idx[:html]=[],[] + @idx[:sst] << "\n\n#{Mx[:br_page_new]}" + @idx[:sst] << "\n\n#{Mx[:lv_o]}2:#{Mx[:lv_c]}Index #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}" + @idx[:sst] << "\n\n#{Mx[:lv_o]}4:idx#{Mx[:lv_c]} [Index] #{Mx[:pa_non_object_dummy_heading]} #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}" the_idx.each do |i| i.each do |x| if x.class == String - print "\n" + x + ', ' + @idx[:sst] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } + aname=x.gsub(/\s+/,'_') + @idx[:html] << %{\n

#{x}, } + @o=@idx[:sst].index(@idx[:sst].last) #@o=@idx[:sst].length - 1 + @q=@idx[:html].index(@idx[:html].last) #@o=@idx[:html].length - 1 + print "\n" + x + ', ' if @md.cmd =~/V/ elsif x.class == Array p 'array error? -->' print x @@ -175,43 +193,55 @@ module SiSU_book_index if x['a1'].class == Array x['a1'].each do |a| if a[:range] - print a[:range] + ', ' + @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, } + @idx[:html][@q]=@idx[:html][@q] + %{#{a[:range]}, } + print a[:range] + ', ' if @md.cmd =~/V/ elsif a[:ocn] - print a[:ocn] + ', ' + @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, } + @idx[:html][@q]=@idx[:html][@q] + %{#{a[:ocn]}, } + print a[:ocn] + ', ' if @md.cmd =~/V/ else p 'error' end end + @idx[:html][@q]=@idx[:html][@q] + '

' end if x['b1'] m=x['b1'] m=m.sort m.each do |k,y| if k !~/a1/ - print "\n\t" + k + ', ' - #p y + @idx[:sst][@o]=@idx[:sst][@o] + %{#{k}, } + @idx[:html][@q]=@idx[:html][@q] + %{\n

#{k}, } + print "\n\t" + k + ', ' if @md.cmd =~/V/ y.each do |z| if z[:range] - print z[:range] + ', ' + @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, } + @idx[:html][@q]=@idx[:html][@q] + %{#{z[:range]}, } + print z[:range] + ', ' if @md.cmd =~/V/ elsif z[:ocn] - print z[:ocn] + ', ' + @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, } + @idx[:html][@q]=@idx[:html][@q] + %{#{z[:ocn]}, } + print z[:ocn] + ', ' if @md.cmd =~/V/ else p 'error' end end + @idx[:html][@q]=@idx[:html][@q] + '

' end end end + @idx[:sst][@o]=@idx[:sst][@o] + " #{Mx[:id_o]}~0;0:0;x#{@x}#{Mx[:id_c]}" + @x +=1 end end end + print "\n" if @md.cmd =~/V/ + @idx end - def screen_html(the_idx) - @file_index_all << %{\n } + def screen_print(the_idx) the_idx.each do |i| i.each do |x| if x.class == String - @file_index_all << %{\n

#{x}, } - #@file_index_all << %{
\n#{x}, } - print %{
\n#{x}, } + print "\n" + x + ', ' elsif x.class == Array p 'array error? -->' print x @@ -219,36 +249,28 @@ module SiSU_book_index if x['a1'].class == Array x['a1'].each do |a| if a[:range] - @file_index_all << %{#{a[:range]}, } - print %{#{a[:range]}, } + print a[:range] + ', ' elsif a[:ocn] - @file_index_all << %{#{a[:ocn]}, } - print %{#{a[:ocn]}, } + print a[:ocn] + ', ' else p 'error' end end - @file_index_all << '

' end if x['b1'] m=x['b1'] m=m.sort m.each do |k,y| if k !~/a1/ - @file_index_all << %{\n

#{k}, } - #@file_index_all << %{
\n\t#{k}, } - print %{
\n\t#{k}, } + print "\n\t" + k + ', ' #p y y.each do |z| if z[:range] - @file_index_all << %{#{z[:range]}, } - print %{#{z[:range]}, } + print z[:range] + ', ' elsif z[:ocn] - @file_index_all << %{#{z[:ocn]}, } - print %{#{z[:ocn]}, } + print z[:ocn] + ', ' else p 'error' end end - @file_index_all << '

' end end end @@ -256,49 +278,18 @@ module SiSU_book_index end end end - def screen_sisu_markup(the_idx) - the_idx.each do |i| - i.each do |x| - if x.class == String - print %{\n\n#{Mx[:fa_bold_o]}#{x}#{Mx[:fa_bold_c]}, } - #print %{\n\n#{Mx[:gr_o]}\n#{Mx[:fa_bold_o]}#{x}#{Mx[:fa_bold_c]}, } - #print "\n" + x + ', ' - elsif x.class == Array - p 'array error? -->' - print x - elsif x.class == Hash - if x['a1'].class == Array - x['a1'].each do |a| - if a[:range] - print %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, } - elsif a[:ocn] - print %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, } - else p 'error' - end - end - end - if x['b1'] - m=x['b1'] - m=m.sort - m.each do |k,y| - if k !~/a1/ - print %{\n #{k}, } - #print "\n\t" + k + ', ' - y.each do |z| - if z[:range] - print %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, } - elsif z[:ocn] - print %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, } - else p 'error' - end - end - puts " #{Mx[:id_o]}~0;0:0;u0#{Mx[:id_c]}" - end - end - end + def clean_and_insert_index(data,sisu_markup_idx) + tuned_file=[] + data.each do |para| + para.gsub!(/\n*#{@rgx_idx}/m,'') + tuned_file << para + if para =~/#{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) tuned_file=[] diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index 80635f36..cbcd42f9 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -357,6 +357,7 @@ module SiSU_Syntax line.gsub!(/_<(br(?: \/)?)_>/,'<\1>') #convert

back, clumsy line.gsub!(/(^|#{Mx[:gl_c]}|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert

back, clumsy line.gsub!(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n#{Mx[:nbsp]}#{Mx[:nbsp]}") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n") + line else # 0~ end line diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index e73157bd..df53d1b7 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -173,9 +173,6 @@ module SiSU_HTML @md.file_type='html' if @md.cmd =~/[hon]/ directories newfilename=%{#{@env.path.output}/#{@md.fnb}/#{@md.fn[:index]}} if @md.file_type =~/html/ - my_make_source_file=SiSU_Env::Create_file.new(@md.cmd,@md.fns) - @fnm=my_make_source_file.marshal_meta - @tune_verse_marshal=my_make_source_file.marshal_tune dal_array=@particulars.dal_array # dal file drawn here @tuned_file_array=SiSU_Tune::Tune.new(dal_array,@md).songsheet @tuned_file_array diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index 8d89de28..796c3939 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -62,14 +62,43 @@ module SiSU_HTML_seg require "#{SiSU_lib}/shared_html" require "#{SiSU_lib}/html" require "#{SiSU_lib}/html_promo" + class Seg_output + def initialize(outputfile,seg,minitoc,type='') + @output_seg_file,@seg,@minitoc,@type=outputfile,seg,minitoc,type + end + def output #CONSIDER + if @seg[:title] =~/\S/ #kludge (for exception file better.ways, how ironic) get a real ruby test, e.g. test that not array or... + filename_seg=[] + filename_seg << @seg[:title] << @seg[:tocband_banner] + if @type =~/endnote/ +#p @seg[:headers] #FIX endnote header + filename_seg << @seg[:header_endnotes] << @minitoc << @seg[:headers] << %{\n
\n} << @seg[:endnote_all] << '
' # << '' + elsif @type =~/idx/ +#p @seg[:headers] #FIX inserted index header + filename_seg << @seg[:header_idx] << @minitoc << @seg[:headers] << %{\n
\n} << @seg[:idx] << '
' # << '' + else + filename_seg << @minitoc << @seg[:headers] << @seg[:main] << "\n\n" + end + filename_seg << @seg[:tail] << @seg[:tocband_bannerless] << @seg[:credits] + filename_seg.flatten!.compact! + filename_seg.each do |para| + unless para =~/\A\s*\Z/ + para.strip! + @output_seg_file << para + end + end + @output_seg_file.close + end + end + end class Seg @@seg,@@seg_subtoc,@@seg_endnotes,@@seg_ad={},{},{},{} - @@seg_name,@@seg_name_html,@@seg_name_php=[],[],[] - @@filename_seg=@@filename_segphp=@@seg_url=@@fn=@@to_lev4=@@get_hash_to=@@get_hash_fn='' + @@seg_name,@@seg_name_html=[],[] + @@seg_url=@@fn=@@to_lev4=@@get_hash_to=@@get_hash_fn='' @@loop_count=@@seg_total=@@tracker=0 @@is4=@@is3=@@is2=@@is1=0 @@header1=@@header2=@@header3=@@header4=0 - @@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:title],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(10){[]} + @@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:title],@@seg[:headers],@@seg[:main],@@seg[:idx],@@seg[:tail],@@seg[:credits],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(11){[]} @@seg[:header_endnotes]='' @@tablehead,@@number_of_cols=0,0 @@flag_alt=false @@ -85,7 +114,7 @@ module SiSU_HTML_seg end def songsheet begin - @@minitoc=SiSU_HTML::Source::Toc.new(@data,@md).minitoc + @minitoc=SiSU_HTML::Source::Toc.new(@data,@md).minitoc data=get_subtoc_endnotes(@data) data=articles(data) Seg.new.cleanup # (((( added )))) @@ -103,6 +132,13 @@ module SiSU_HTML_seg @h_sfx='.php' if @md.file_type =~/php/ @h_sfx=@md.sfx if @md.file_type =~/html/ @h_sfx='.html' if @md.file_type =~/html/ #used in creating file, not to be omitted. + idx_html=nil + if @md.book_index + my_make_source_file=SiSU_Env::Create_file.new(@md.cmd,@md.fns) + idx_html=SiSU_Particulars::Combined_singleton.instance.get_html_idx(@md.opt).html_idx + idx_html.each {|x| @@seg[:idx] << x } + @@seg[:header_idx]='' + end data.each do |para| if para =~/^#{Mx[:lv_o]}4:/ @@seg_name << para[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}/,1] @@ -153,20 +189,24 @@ module SiSU_HTML_seg mkdir_p(@md.dir_out) unless FileTest.directory?(@md.dir_out) #bug - added specifically for nav! not needed by regular seg, check !!! Seg.new('',@md).tail segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking-1]}#{@md.fnl[:mid]}#@h_sfx#{@md.fnl[:post]}" - @@filename_seg=File.new(segfilename,'w') if @@seg_name_html[tracking-1] - unless (@@seg_name_html[tracking-1] =~/endnotes/) - Seg.new.output - else Seg.new.output('endnotes') + @output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1] + if @@seg_name_html[tracking-1] !~/endnotes|idx/ + Seg_output.new(@output_seg_file,@@seg,@minitoc).output + elsif @@seg_name_html[tracking-1] =~/endnotes/ + Seg_output.new(@output_seg_file,@@seg,@minitoc,'endnotes').output + elsif @@seg_name_html[tracking-1] =~/idx/ + Seg_output.new(@output_seg_file,@@seg,@minitoc,'idx').output + else p 'check' end Seg.new.reinitialise header_art(para) head(para) if @@seg_name_html[tracking] =~/metadata/ # this is for metadata segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking]}#{@md.fnl[:mid]}#@h_sfx#{@md.fnl[:post]}" - @@filename_seg=File.new(segfilename,'w') - Seg.new.reinitialise + @output_seg_file=File.new(segfilename,'w') + Seg.new.reinitialise #BUG with items following endnote, and occurring before metadata, this becomes a bug ... work area for book index, FIX flagend="x" - @@filename_seg.close #%(((( EOF )))) --> + @output_seg_file.close #%(((( EOF )))) --> end end if tracking == 0 @@ -391,26 +431,6 @@ module SiSU_HTML_seg ads=SiSU_HTML_promo::Ad.new(@md) @@seg[:credits] << format_head_seg.credit << ads.div.close << ads.display << format_head_seg.html_close end - def output(type='') - if @@seg[:title] =~/\S/ #kludge (for exception file better.ways, how ironic) get a real ruby test, e.g. test that not array or... - filename_seg=[] - filename_seg << @@seg[:title] << @@seg[:tocband_banner] - if type !~/endnote/ - filename_seg << @@minitoc << @@seg[:headers] << @@seg[:main] << "\n\n" - else - filename_seg << @@seg[:header_endnotes] << @@minitoc << @@seg[:headers] << %{\n
\n} << @@seg[:endnote_all] << '
' - end - filename_seg << @@seg[:tail] << @@seg[:tocband_bannerless] << @@seg[:credits] - filename_seg.flatten!.compact! - filename_seg.each do |para| - unless para =~/\A\s*\Z/ - para.strip! - @@filename_seg << para - end - end - @@filename_seg.close - end - end def reinitialise @@seg[:title],@@seg[:dot_nav],@@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(8){[]} @@segtocband=nil @@ -433,11 +453,9 @@ module SiSU_HTML_seg @@seg_endnotes_array=[] if para=~/^#{Mx[:lv_o]}4:/ @@fns_previous=@md.fns if para=~/^#{Mx[:lv_o]}1:meta#{Mx[:lv_c]}/ end - if para =~/^#{Mx[:lv_o]}4:/ #% EXTRACTION OF SUB-TOCs + if para =~/^#{Mx[:lv_o]}4:/ #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs @@seg_subtoc[@@fn]=@@seg_subtoc_array @@seg_subtoc_array=[] - end - if para =~/^#{Mx[:lv_o]}4:/ #% SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs if para !~/^#{Mx[:lv_o]}4:metadata#{Mx[:lv_c]}/ m=para[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}.+?#{Mx[:id_o]}~(\d+);(?:[oh]|4:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] end diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index d6558634..05a6272c 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -439,6 +439,7 @@ module SiSU_ODF bullet=image_src('bullet_09.png') cp("#{bullet}/bullet_09.png","#{@env.path.odf}/Pictures/.") #if image_src('bullet_09.png') data.each do |para| + para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove #p para if para =~safe_characters and @md.cmd =~/V/ #KEEP #para.gsub!(/<(~\d+;(?:\w|[0-6]:)\d+;\w\d+)><(#@dp:#@dp)>/,'<\1><\2>') para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ diff --git a/lib/sisu/v0/particulars.rb b/lib/sisu/v0/particulars.rb index 8ae4f66e..59b8956b 100644 --- a/lib/sisu/v0/particulars.rb +++ b/lib/sisu/v0/particulars.rb @@ -92,7 +92,11 @@ module SiSU_Particulars set_env set_md end - attr_accessor :opt,:md + def get_html_idx(opt) + @opt=opt + set_html_idx + end + attr_accessor :opt,:md,:html_idx def set_md begin @md=SiSU_Param::Parameters.new(@opt).get @@ -116,6 +120,13 @@ module SiSU_Particulars rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error end end + def set_html_idx + begin + @html_idx=SiSU_DAL::Source.new(@md).get_idx_html + self + rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + end + end end end __END__ diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index fb4b1115..754e366d 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -275,6 +275,7 @@ WOK table_message='[table omitted, see other document formats]' fix=[] data.each do |para| + para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#@br#{table_message}") para.gsub!(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,'') # remove dummy headings (used by html) #check para.gsub!(/#{Mx[:gl_bullet]}\s*/,'* ') # bullet markup, marked down diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index bf59830f..41e8c393 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -423,13 +423,11 @@ module SiSU_XML_munge %{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, '\1\2') #escaped urls not linked, deal with later - para.gsub!(/ |#{Mx[:nbsp]}/,' ') - #para.gsub!(/ /,' ') #clean else para.gsub!(/(^|[^}])_/m,'\1>') #code-block: angle brackets special characters para.gsub!(/(^|[^}])_/m,'\1>') - para.gsub!(/ |#{Mx[:nbsp]}/,' ') end + para.gsub!(/ |#{Mx[:nbsp]}/m,' ') para end def markup_light(para='') diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index 93e6ea8e..25cf90ec 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -3033,12 +3033,18 @@ WOK def file_meta File.new("#{@env.path.dal}/#@fns.meta",'w+') end + def file_meta_idx_html + File.new("#{@env.path.dal}/#@fns.idx.html",'w+') + end def file_note File.new("#{Dir.pwd}/#@fns.fn",'w+') end def marshal_meta "#{@env.path.dal}/#@fns.meta.rbm" end + def marshal_meta_idx_html + "#{@env.path.dal}/#@fns.idx_html.rbm" + end def meta "#{@env.path.dal}/#@fns.meta" end diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index 3cf560c4..885643cf 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -693,6 +693,7 @@ WOK paranum=if ocn; para[m,2] else '' end + paranum = '' if paranum.to_i == 0 txt_obj={:txt =>parablock,:ocn =>paranum} do_duo=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj) para=do_duo.para_num if parablock -- cgit v1.2.3