From 1625f316c0d74e01789bec8b8fca0608acc9310e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 20 Nov 2014 23:03:24 -0500 Subject: d: html, segments, reorganize, introduce new file --- data/doc/sisu/CHANGELOG_v6 | 2 + lib/sisu/develop/html.rb | 9 +- lib/sisu/develop/html_format.rb | 44 ++--- lib/sisu/develop/html_manifest.rb | 8 + lib/sisu/develop/html_persist.rb | 237 +++++++++++++++++++++++++ lib/sisu/develop/html_segments.rb | 356 +++++++++++++++++++------------------- 6 files changed, 444 insertions(+), 212 deletions(-) create mode 100644 lib/sisu/develop/html_persist.rb diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 4299810c..6a45a761 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -71,6 +71,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.4.0.orig.tar.xz * orgmode, add orgmode structure output to txts + * html, segments, reorganize, introduce new file + ** SiSU "UnFrozen" - prior to end of Debian Freeze (upstream bugfix 6.3.2 (5.7.2) intended for Jessie (packaged for Debian as 5.7.1-2) was not accepted) diff --git a/lib/sisu/develop/html.rb b/lib/sisu/develop/html.rb index 1f128afc..737d532e 100644 --- a/lib/sisu/develop/html.rb +++ b/lib/sisu/develop/html.rb @@ -165,11 +165,10 @@ module SiSU_HTML end end SiSU_Env::Clear.new(@opt.selections.str,@opt.fns,@md).param_instantiate - @@flag,@@scr,@@seg,@@seg_endnotes,@@seg_subtoc,@@seg_ad={},{},{},{},{},{} - @@seg_total,@@tracker,@@loop_count,@@tablehead,@@number_of_cols=0,0,0,0,0 - @@seg_name,@@seg_name_html,@@seg_subtoc_array,@@seg_endnotes_array,@@segtocband,@@tablefoot=Array.new(7){[]} - @@filename_seg,@@seg_url,@@fn,@@to_lev4,@@get_hash_to,@@get_hash_fn='','','','','','','' - @@is4=@@is3=@@is2=@@is1=@@heading1=@@heading2=@@heading3=@@heading4=0 + @@flag,@@scr,@@seg,@@seg_endnotes,@@seg_subtoc={},{},{},{},{} + @@tracker=0 + @@seg_name,@@seg_name_x,@@seg_subtoc_array,@@seg_endnotes_array,@@tablefoot=Array.new(5){[]} + @@filename_seg,@@seg_url,@@to_lev4,@@get_hash_to,@@get_hash_fn='','','','','' end end private diff --git a/lib/sisu/develop/html_format.rb b/lib/sisu/develop/html_format.rb index b69c5d86..5d7a4a7d 100644 --- a/lib/sisu/develop/html_format.rb +++ b/lib/sisu/develop/html_format.rb @@ -84,10 +84,12 @@ module SiSU_HTML_Format end end def id #w3c? "tidy" complains about numbers as identifiers ! annoying - (@ocn==nil || @ocn.empty?) ? '' : %{id="#{Mx[:ocn_id_char]}#{@ocn}"} + (@ocn==nil || @ocn.empty?) \ + ? '' : %{id="#{Mx[:ocn_id_char]}#{@ocn}"} end def goto - (@ocn==nil || @ocn.empty?) ? '' : %{} + (@ocn==nil || @ocn.empty?) \ + ? '' : %{} end end class HeadInformation @@ -99,8 +101,9 @@ module SiSU_HTML_Format @md=md # DublinCore 1 - title @bits=SiSU_Proj_HTML::Bits.new - @seg_name_html=(SiSU_HTML::Source::Seg.new.seg_name_html || []) - @seg_name_html_tracker=(SiSU_HTML::Source::Seg.new.seg_name_html_tracker || []) + @per=SiSU_HTML_Persist::Persist.new + @per.seg_name_x=SiSU_HTML::Seg.new.seg_name_x + @per.seg_name_x_tracker=SiSU_HTML::Seg.new.seg_name_x_tracker @tocband_scroll,@tocband_segtoc=nil,nil @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure @@ -403,7 +406,7 @@ WOK - #{@md.html_title} + #{@md.title.full} #{rdf.metatag_html} @@ -615,9 +618,9 @@ WOK super(md) end def dot_control_pre_next - pre="#{@seg_name_html[@seg_name_html_tracker-1]}#{@md.lang_code_insert}#{Sfx[:html]}" + pre="#{@per.seg_name_x[@per.seg_name_x_tracker-1]}#{@md.lang_code_insert}#{Sfx[:html]}" up=@toc - nxt="#{@seg_name_html[@seg_name_html_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}" + nxt="#{@per.seg_name_x[@per.seg_name_x_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}" if nxt=~/sisu_manifest\.html/ @file=SiSU_Env::FileOp.new(@md) if @md if @file.output_dir_structure.by_language_code? \ @@ -643,7 +646,7 @@ WOK #{the_table_close}} end def dot_control_pre - pre="#{@seg_name_html[@seg_name_html_tracker-2]}#{@md.lang_code_insert}#{Sfx[:html]}" + pre="#{@per.seg_name_x[@per.seg_name_x_tracker-2]}#{@md.lang_code_insert}#{Sfx[:html]}" up=@toc nxt="#{@md.file.base_filename.html_segtoc}" %{ @@ -671,12 +674,12 @@ WOK } pre=%{} if f_pre==true nxt=%{} if f_nxt==true @@ -721,23 +724,6 @@ WOK else '' end end - def navigation_table - %{
- + #{png_nav.pre} - + #{png_nav.nxt}
-
- - - } - end - def navigation_table1 - %{ -
- } - end - def navigation_table2 - %{ -
- } - end def credit %{
@@ -799,8 +785,8 @@ WOK - #{@seg_name_html[@seg_name_html_tracker]} - - #{@md.html_title} + #{@per.seg_name_x[@per.seg_name_x_tracker]} - + #{@md.title.main} #{rdf.metatag_html} diff --git a/lib/sisu/develop/html_manifest.rb b/lib/sisu/develop/html_manifest.rb index fc07a4c7..3e61d29b 100644 --- a/lib/sisu/develop/html_manifest.rb +++ b/lib/sisu/develop/html_manifest.rb @@ -517,6 +517,14 @@ module SiSU_Manifest file=@f.base_filename.rst summarize(id,file,pth,rel,url) end + if FileTest.file?(@f.place_file.orgmode.dir)==true + id='OrgMode structure text (UTF-8)' + pth=@f.output_path.orgmode.dir + rel=@f.output_path.orgmode.rel_sm + url=@f.output_path.orgmode.url + file=@f.base_filename.orgmode + summarize(id,file,pth,rel,url) + end if FileTest.file?("#{@base_path}/#{@md.fns}.tex")==true id,file='LaTeX (portrait)',"#{@md.fns}.tex" pth,rel,url='','','' diff --git a/lib/sisu/develop/html_persist.rb b/lib/sisu/develop/html_persist.rb new file mode 100644 index 00000000..482a0c00 --- /dev/null +++ b/lib/sisu/develop/html_persist.rb @@ -0,0 +1,237 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** html segment generation, processing + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_HTML_Persist + class Persist + @@persist=nil + attr_accessor :is0,:is1,:is2,:is3,:is4,:heading0,:heading1,:heading2,:heading3,:heading4, :title, :dot_nav, :tocband_banner, :tocband_bannerless, :headings, :heading_endnotes, :main, :endnote_all, :tail, :credits, :heading_idx, :idx, :seg_endnotes, :seg_endnotes_array, :segtocband, :get_hash_fn, :get_hash_to, :seg_subtoc, :seg_subtoc_array, :fn, :seg_name ,:seg_name_x,:seg_name_x_tracker + def initialize(args=nil) + @@persist=args=(args ? args : (@@persist || persist_init_hash_values)) + @is0=args[:is0] + @is1=args[:is1] + @is2=args[:is2] + @is3=args[:is3] + @is4=args[:is4] + @heading0=args[:heading0] + @heading1=args[:heading1] + @heading2=args[:heading2] + @heading3=args[:heading3] + @heading4=args[:heading4] + @title=args[:title] + @dot_nav=args[:dot_nav] + @tocband_banner=args[:tocband_banner] + @tocband_bannerless=args[:tocband_bannerless] + @headings=args[:headings] + @heading_endnotes=args[:heading_endnotes] + @main=args[:main] + @endnote_all=args[:endnote_all] + @tail=args[:tail] + @credits=args[:credits] + @heading_idx=args[:heading_idx] + @idx=args[:idx] + @seg_endnotes=args[:seg_endnotes] + @seg_endnotes_array=args[:seg_endnotes_array] + @get_hash_to=args[:get_hash_to] + @get_hash_fn=args[:get_hash_fn] + @seg_subtoc=args[:seg_subtoc] + @seg_subtoc_array=args[:seg_subtoc_array] + @segtocband=args[:fn] + @fn=args[:fn] + @seg_name=args[:seg_name] + @seg_name_x=args[:seg_name_x] + @seg_name_x_tracker=args[:seg_name_x_tracker] + end + def is0 + @is0 + end + def is1 + @is1 + end + def is2 + @is2 + end + def is3 + @is3 + end + def is4 + @is4 + end + def heading0 + @heading0 + end + def heading1 + @heading1 + end + def heading2 + @heading2 + end + def heading3 + @heading3 + end + def heading4 + @heading4 + end + def title + @title + end + def dot_nav + @dot_nav + end + def tocband_banner + @tocband_banner + end + def tocband_bannerless + @tocband_bannerless + end + def headings + @headings + end + def heading_endnotes + @heading_endnotes + end + def main + @main + end + def endnote_all + @endnote_all + end + def tail + @tail + end + def credits + @credits + end + def heading_idx + @heading_idx + end + def idx + @idx + end + def seg_endnotes + @seg_endnotes + end + def seg_endnotes_array + @seg_endnotes_array + end + def get_hash_to + @get_hash_to + end + def get_hash_fn + @get_hash_fn + end + def seg_subtoc + @seg_subtoc + end + def seg_subtoc_array + @seg_subtoc_array + end + def segtocband + @segtocband + end + def fn + @fn + end + def seg_name + @seg_name + end + def seg_name_x + @seg_name_x + end + def seg_name_x_tracker + @seg_name_x_tracker + end + def persist_init_hash_values + { + is0: 0, + is1: 0, + is2: 0, + is3: 0, + is4: 0, + heading0: '', + heading1: '', + heading2: '', + heading3: '', + heading4: '', + tocband_banner: [], + tocband_bannerless: [], + title: [], + headings: [], + main: [], + idx: [], + tail: [], + credits: [], + endnote_all: [], + heading_endnotes: '', + seg_endnotes: {}, + seg_endnotes_array: [], + get_hash_fn: '', + get_hash_to: '', + seg_subtoc: {}, + seg_subtoc_array: [], + segtocband: '', + fn: '', + seg_name: [], + seg_name_x: [], + seg_name_x_tracker: 0, + } + end + def persist_init + @@persist=nil + Persist.new(persist_init_hash_values) + end + end +end +__END__ diff --git a/lib/sisu/develop/html_segments.rb b/lib/sisu/develop/html_segments.rb index 61bed7bf..d6a76de6 100644 --- a/lib/sisu/develop/html_segments.rb +++ b/lib/sisu/develop/html_segments.rb @@ -57,12 +57,13 @@ module SiSU_HTML_Seg require_relative 'html_shared' # html_shared.rb require_relative 'html' # html.rb + require_relative 'html_persist' # html_persist.rb require_relative 'html_promo' # html_promo.rb require_relative 'shared_metadata' # shared_metadata.rb class Output - def initialize(md,outputfile,seg,minitoc,type='') - @md, @output_seg_file,@seg,@minitoc,@type= - md,outputfile, seg,minitoc, type + def initialize(md,outputfile,per,minitoc,type='') + @md, @output_seg_file,@per,@minitoc,@type= + md,outputfile, per,minitoc, type @title_banner_=SiSU_Env::CreateSite.new(@md.opt).html_seg_title_banner? @file=SiSU_Env::FileOp.new(@md) @make=SiSU_Env::ProcessingSettings.new(@md) @@ -71,67 +72,68 @@ module SiSU_HTML_Seg : 'content0' end def output - if @seg[:title] =~/\S/ + if @per.title =~/\S/ filename_seg=[] if @make.build.html_top_band? filename_seg \ - << @seg[:title] \ - << @seg[:tocband_banner] + << @per.title \ + << @per.tocband_banner else filename_seg \ - << @seg[:title] + << @per.title end if @type=='endnotes' - @seg[:headings]=[] + @per.headings=[] format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) if @title_banner_ - @seg[:headings] \ + @per.headings \ << format_head_seg. title_banner(@md.title.main,@md.title.sub,@author) end txt_obj={ txt: 'Endnotes', ocn_display: '' } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) - @seg[:headings] \ + @per.headings \ << format_seg.title_heading1 filename_seg \ - << @seg[:heading_endnotes] \ - << @minitoc << @seg[:headings] \ + << @per.heading_endnotes \ + << @minitoc << @per.headings \ << %{\n
\n} \ - << @seg[:endnote_all] \ + << @per.endnote_all \ << '
' # << '
' elsif @type=='idx' - @seg[:headings]=[] + @per.headings=[] format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) if @title_banner_ - @seg[:headings] \ + @per.headings \ << format_head_seg. title_banner(@md.title.main,@md.title.sub,@author) end txt_obj={ txt: 'Index', ocn_display: '' } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) - @seg[:headings] << format_seg.title_heading1 + @per.headings << format_seg.title_heading1 filename_seg \ - << @seg[:heading_idx] \ - << @minitoc << @seg[:headings] \ + << @per.heading_idx \ + << @minitoc << @per.headings \ << %{\n
\n} \ - << @seg[:idx] \ + << @per.idx \ << '
' # << '' elsif @type=='metadata' metadata=SiSU_Metadata::Summary.new(@md).html_display.metadata - @seg[:headings]=[] + @per.headings=[] format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) if @title_banner_ - @seg[:headings] \ + @per.headings \ << format_head_seg. title_banner(@md.title.main,@md.title.sub,@author) end txt_obj={ txt: 'Metadata', ocn_display: '' } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) - @seg[:headings] << format_seg.title_heading1 + @per.headings \ + << format_seg.title_heading1 filename_seg \ - << @seg[:heading_idx] \ + << @per.heading_idx \ << @minitoc \ - << @seg[:headings] \ + << @per.headings \ << %{\n
\n} \ << metadata \ << '
' # << '' @@ -139,23 +141,23 @@ module SiSU_HTML_Seg if @make.build.html_top_band? filename_seg \ << @minitoc \ - << @seg[:headings] \ - << @seg[:main] \ + << @per.headings \ + << @per.main \ << "\n\n" else filename_seg \ << @minitoc \ - << @seg[:main] \ + << @per.main \ << "\n\n" end end filename_seg <<=if @make.build.html_top_band? - @seg[:tail] \ - << @seg[:tocband_bannerless] \ - << @seg[:credits] + @per.tail \ + << @per.tocband_bannerless \ + << @per.credits else - @seg[:tail] \ - << @seg[:credits] + @per.tail \ + << @per.credits end filename_seg=filename_seg.flatten.compact #watch filename_seg.each do |str| @@ -173,32 +175,15 @@ module SiSU_HTML_Seg end end class Seg - @@seg,@@seg_subtoc,@@seg_endnotes,@@seg_ad={},{},{},{} - @@seg_name,@@seg_name_html=[],[] - @@seg_url=@@fn=@@get_hash_to=@@get_hash_fn='' - @@loop_count=@@seg_total=@@tracker=0 - @@is4=@@is3=@@is2=@@is1=@@is0=0 - @@heading0=@@heading1=@@heading2=@@heading3=@@heading4=0 - @@seg[:tocband_banner], - @@seg[:tocband_bannerless], - @@seg[:title],@@seg[:headings], - @@seg[:main], - @@seg[:idx], - @@seg[:tail], - @@seg[:credits], - @@seg_subtoc_array, - @@seg_endnotes_array, - @@seg[:endnote_all]= - Array.new(11){[]} - @@seg[:heading_endnotes]='' - @@tablehead,@@number_of_cols=0,0 - @@dp,@@segtocband=nil,nil - @@fns_previous='' - attr_reader :seg_name_html,:seg_name_html_tracker + @@seg_url='' + @@tracker=0 + @@seg_name=[] + attr_reader :seg_name_x,:seg_name_x_tracker def initialize(md=nil,data='') @md,@data=md,data - @seg_name_html=@@seg_name_html || nil - @seg_name_html_tracker=@@tracker || nil + @per=SiSU_HTML_Persist::Persist.new + @seg_name_x=@per.seg_name_x=(@@seg_name || []) + @seg_name_x_tracker=@per.seg_name_x_tracker=(@@tracker || 0) @env=SiSU_Env::InfoEnv.new(@md.fns) if @md if @md @make=SiSU_Env::ProcessingSettings.new(@md) @@ -214,22 +199,24 @@ module SiSU_HTML_Seg def songsheet begin @minitoc=SiSU_HTML::Source::Toc.new(@md,@data).minitoc - data=get_subtoc_endnotes(@data) - data=articles(data) - SiSU_HTML_Seg::Seg.new.cleanup # (((( added )))) + SiSU_HTML_Persist::Persist.new.persist_init + @per=SiSU_HTML_Persist::Persist.new + data=get_subtoc_endnotes(@data,@per) + data=articles(data,@per) + cleanup(@md,@per) # (((( added )))) #### (((( END )))) #### rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do __LINE__.to_s + ':' + __FILE__ end ensure - @@seg_name=[] + @@seg_name=@per.seg_name=[] end end protected - def articles(data) + def articles(data,per) + @per=per tracking,newfile=0,0 - @@is4=@@is3=@@is2=@@is1=@@is0=0 printed_endnote_seg='n' idx_html=nil if @md.book_idx @@ -237,27 +224,28 @@ module SiSU_HTML_Seg idx_html=SiSU_Particulars::CombinedSingleton. instance.get_idx_html(@md.opt).html_idx idx_html.each do |x| - @@seg[:idx] << x + @per.idx << x end - @@seg[:heading_idx]='' + @per.heading_idx='' end data.each do |dob| if (dob.is == :heading \ || dob.is == :heading_insert) \ && dob.ln == 4 @@seg_name << dob.name + @per.seg_name = @@seg_name dob.name end end - @@seg_name_html=@@seg_name - @@seg_total=@@seg_name.length - testforartnum=@@seg_name_html + @per.seg_name_x=@per.seg_name + @per.seg_name.length + testforartnum=@per.seg_name_x if (@md.opt.act[:verbose][:set]==:on \ || @md.opt.act[:verbose_plus][:set]==:on \ || @md.opt.act[:maintenance][:set]==:on) SiSU_Screen::Ansi.new( @md.opt.act[:color_state][:set], - @@seg_name.length + @per.seg_name.length ).segmented end map_nametags=SiSU_Particulars::CombinedSingleton. @@ -285,41 +273,41 @@ module SiSU_HTML_Seg if (dob.is==:heading \ || dob.is==:heading_insert) \ && dob.ln==4 - @@heading4=dob.obj - @@is4=newfile=1 + @per.heading4=dob.obj + @per.is4=newfile=1 end if (dob.is==:heading \ || dob.is==:heading_insert) \ && dob.ln==3 - @@heading3=dob.obj - @@is4,@@is3=0,1 + @per.heading3=dob.obj + @per.is4,@per.is3=0,1 end if (dob.is==:heading \ || dob.is==:heading_insert) \ && dob.ln==2 - @@heading2=dob.obj - @@is4,@@is3,@@is2=0,0,1 + @per.heading2=dob.obj + @per.is4,@per.is3,@per.is2=0,0,1 end if (dob.is==:heading \ || dob.is==:heading_insert) \ && dob.ln==1 - @@heading1=dob.obj - @@is4,@@is3,@@is2,@@is1=0,0,0,1 + @per.heading1=dob.obj + @per.is4,@per.is3,@per.is2,@per.is1=0,0,0,1 end if (dob.is==:heading \ || dob.is==:heading_insert) \ && dob.ln==0 - @@heading0=dob.obj - @@is4,@@is3,@@is2,@@is1,@@is0=0,0,0,0,1 + @per.heading0=dob.obj + @per.is4,@per.is3,@per.is2,@per.is1,@per.is0=0,0,0,0,1 end - if (@@is1 && !@@is2 && !@@is3 && !@@is4) + if (@per.is1 && !@per.is2 && !@per.is3 && !@per.is4) if not (dob.is==:heading \ || dob.is==:heading_insert) \ && dob.ln==0 $_ #; check end end - if @@is4==1 + if @per.is4==1 if newfile==1 \ or dob.obj =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/ newfile=0 @@ -332,43 +320,46 @@ module SiSU_HTML_Seg FileUtils::mkdir_p(@file.output_path.html_seg.dir) \ if File.writable?("#{@file.output_path.base.dir}/.") end - SiSU_HTML_Seg::Seg.new(@md).tail + tail(@md,@per) + #SiSU_HTML_Seg::Seg.new(@md,@per).tail fnh={ - fn: @@seg_name_html[tracking-1], + fn: @per.seg_name_x[tracking-1], } fn=@md.file.base_filename.html_seg(fnh) segfilename="#{@file.output_path.html_seg.dir}/#{fn}" - output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1] + output_seg_file=File.new(segfilename,'w') if @per.seg_name_x[tracking-1] minitoc=(@make.build.html_minitoc?) ? @minitoc : '' if dob.is==:heading \ - || (@@seg_name_html[tracking-1] !~/endnotes|book_index|metadata/) - SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc).output + || (@per.seg_name_x[tracking-1] !~/endnotes|book_index|metadata/) + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc).output elsif dob.is==:heading_insert - if @@seg_name_html[tracking-1]=='endnotes' - SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'endnotes').output - elsif @@seg_name_html[tracking-1]=='book_index' - SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'idx').output - @@seg[:idx]=[] - elsif @@seg_name_html[tracking-1]=='metadata' - SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'metadata').output + if @per.seg_name_x[tracking-1]=='endnotes' + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc,'endnotes').output + elsif @per.seg_name_x[tracking-1]=='book_index' + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc,'idx').output + @per.idx=[] + elsif @per.seg_name_x[tracking-1]=='metadata' + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc,'metadata').output else puts "#{__FILE__}::#{__LINE__}" end else puts "#{__FILE__}::#{__LINE__}" end - SiSU_HTML_Seg::Seg.new.reinitialise + SiSU_HTML_Seg::Seg.new.reinitialise(per) + #per=persist_init heading_art(dob) head(dob) #keep use for last segment, eg if metadata is last segment - if @@seg_name_html[tracking] =='metadata' # this is for metadata - fnh={ - fn: @@seg_name_html[tracking], - } - fn=@md.file.base_filename.html_seg(fnh) - segfilename="#{@file.output_path.html_seg.dir}/#{fn}" - output_seg_file=File.new(segfilename,'w') - SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'metadata').output - Seg.new.reinitialise - end + if @per.seg_name_x[tracking] =='metadata' # this is for metadata + fnh={ + fn: @per.seg_name_x[tracking], + } + fn=@md.file.base_filename.html_seg(fnh) + segfilename="#{@file.output_path.html_seg.dir}/#{fn}" + output_seg_file=File.new(segfilename,'w') + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc,'metadata').output + #per=persist_init + Seg.new.reinitialise(per) + end end if tracking==0 heading_art(dob) @@ -381,8 +372,8 @@ module SiSU_HTML_Seg || dob.is==:heading_insert) \ && dob.ln==4 \ && dob.name - @@get_hash_to=dob.name - @@get_hash_fn=dob.name + @per.get_hash_to=dob.name + @per.get_hash_fn=dob.name end if dob.obj.is_a?(String) markup(dob) @@ -402,108 +393,108 @@ module SiSU_HTML_Seg end def heading_art(dob) format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) - @@seg[:dot_nav]=if (@make.build.html_navigation?) \ + @per.dot_nav=if (@make.build.html_navigation?) \ && (@make.build.html_navigation_bar?) x=if (dob.is==:heading \ || dob.is==:heading_insert) \ && (dob.ln.to_s =~/^[0-7]/) - x=if @@tracker < @@seg_total-1 + x=if @@tracker < @per.seg_name.length-1 format_head_seg.dot_control_pre_next else format_head_seg.dot_control_pre end - else @@seg[:dot_nav] + else @per.dot_nav end - else @@seg[:dot_nav]='' + else @per.dot_nav='' end ads=SiSU_HTML_Promo::Ad.new(@md) - @@seg[:title]=format_head_seg.head_seg << ads.div.major + @per.title=format_head_seg.head_seg << ads.div.major end def head(dob) clean=/|<:.*?>/ format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) if @make.build.html_navigation? - if @@tracker < @@seg_total-1 - @@segtocband=if @@tracker==0 + if @@tracker < @per.seg_name.length-1 + @per.segtocband=if @@tracker==0 format_head_seg.toc_next2 else format_head_seg.toc_pre_next2 end - else @@segtocband=format_head_seg.toc_pre2 + else @per.segtocband=format_head_seg.toc_pre2 end - else @@segtocband='' + else @per.segtocband='' end @p_num ||= '' - if @@is0==1 + if @per.is0==1 @author=%{#{@md.author}\n} if @md.author.to_s =~/\S/ - @@seg[:tocband_banner] \ - << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav]) - @@seg[:tocband_bannerless] \ + @per.tocband_banner \ + << format_head_seg.navigation_band(@per.segtocband,@per.dot_nav) + @per.tocband_bannerless \ << '
' \ - << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) + << format_head_seg.navigation_band_bottom(@per.segtocband,@per.dot_nav) if @title_banner_ - @@seg[:headings] \ + @per.headings \ << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author).gsub(clean,'') end - ocn=(@@heading0[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ocn=(@per.heading0[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ ? $1 : '' @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) - txt_obj={ txt: @@heading0, ocn_display: @p_num.ocn_display } + txt_obj={ txt: @per.heading0, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) - @@seg[:headings] \ + @per.headings \ << format_seg.title_heading0.gsub(clean,'') - @@heading0=@@heading0. + @per.heading0=@per.heading0. gsub(/  [\d*+]+<\/sup> <\/a>/,'') end - if @@is1==1 - heading1=@@heading1 + if @per.is1==1 + heading1=@per.heading1 ocn=(heading1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ ? $1 : '' @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading1, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) - @@seg[:headings] \ + @per.headings \ << format_seg.title_heading1.gsub(clean,'') - @@heading1=@@heading1. + @per.heading1=@per.heading1. gsub(/  [\d*+]+<\/sup> <\/a>/,'') end - if @@is2==1 - heading2=@@heading2 + if @per.is2==1 + heading2=@per.heading2 ocn=(heading2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ ? $1 : '' @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) - @@seg[:headings] \ + @per.headings \ << format_seg.title_heading2.gsub(clean,'') - @@heading2=@@heading2. + @per.heading2=@per.heading2. gsub(/  [\d*+]+<\/sup> <\/a>/,'') end - if @@is3==1 - heading3=@@heading3 + if @per.is3==1 + heading3=@per.heading3 ocn=(heading3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ ? $1 : '' @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) - @@seg[:headings] \ + @per.headings \ << format_seg.title_heading3.gsub(clean,'') - @@heading3=@@heading3. + @per.heading3=@per.heading3. gsub(/  [\d*+]+<\/sup> <\/a>/,'') end - if @@is4==1 - heading4=@@heading4 + if @per.is4==1 + heading4=@per.heading4 ocn=(heading4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ ? $1 : '' @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading4, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) - @@seg[:headings] \ + @per.headings \ << format_seg.title_heading4.gsub(clean,'') end @@tracker=@@tracker+1 @@ -586,66 +577,73 @@ module SiSU_HTML_Seg if (dob.is==:heading \ || dob.is==:heading_insert) \ && dob.ln==4 - @@seg[:main] << %{\n
\n} - @@seg[:main] << dob_html + @per.main << %{\n
\n} + @per.main << dob_html if @make.build.segsubtoc? - @@seg[:main] << @@seg_subtoc[@@get_hash_fn] #% insertion of sub-toc + @per.main << @per.seg_subtoc[@per.get_hash_fn] #% insertion of sub-toc end else - @@seg[:main] << dob_html #unless @@flag_alt==true + @per.main << dob_html #unless @@flag_alt==true end end end - def tail + def tail(md,per) + @md,@per=md,per format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) - if @md.flag_auto_endnotes and @@seg_endnotes[@@get_hash_fn] - @@seg[:tail] << %{\n
\n
\n} - if @@seg_endnotes[@@get_hash_fn].flatten.length > 0 - @@seg[:tail] << format_head_seg.endnote_mark - @@seg[:tail] << @@seg_endnotes[@@get_hash_fn].flatten #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| + if @md.flag_auto_endnotes \ + and @per.seg_endnotes[@per.get_hash_fn] + @per.tail << %{\n
\n
\n} + if @per.seg_endnotes[@per.get_hash_fn].flatten.length > 0 + @per.tail << format_head_seg.endnote_mark + @per.tail << @per.seg_endnotes[@per.get_hash_fn].flatten #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| end - @@seg[:tail] << '
' - @@seg[:tail] << '
' #this div closes div class content + @per.tail << '
' + @per.tail << '
' #this div closes div class content end ads=SiSU_HTML_Promo::Ad.new(@md) - @@seg[:credits] << format_head_seg.credit << ads.div.close << ads.display << format_head_seg.html_close + @per.credits \ + << format_head_seg.credit \ + << ads.div.close \ + << ads.display \ + << format_head_seg.html_close end - def reinitialise - @@seg[:title],@@seg[:dot_nav],@@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:headings],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(8){[]} - @@segtocband=nil + def reinitialise(per) + per.title,per.dot_nav,per.tocband_banner,per.tocband_bannerless,per.headings,per.main,per.tail,per.credits=Array.new(8){[]} + @per.segtocband=nil end - def cleanup - reinitialise - @@seg_total,@@tracker=0,0 - @@seg_endnotes,@@seg_subtoc={},{} - @@seg_endnotes_array,@@seg_subtoc_array=[],[] - @@seg[:endnote_all]=[] + def cleanup(md,per) + #per=persist_init + reinitialise(per) + @@tracker=0 + @per.seg_endnotes,@per.seg_subtoc={},{} + @per.seg_endnotes_array,@per.seg_subtoc_array=[],[] + per.endnote_all=[] end - def get_subtoc_endnotes(data) #get endnotes & sub-table of contents subtoc + def get_subtoc_endnotes(data,per) #get endnotes & sub-table of contents subtoc + @per=per data.each do |dob| dob.obj=dob.obj.gsub(/
(.+?)<\/a>/mi,'\1') if @md.flag_auto_endnotes if (dob.is==:heading \ || dob.is==:heading_insert) \ && (dob.ln.to_s =~/^[0-4]/) \ - and not @@fn.to_s.empty? - @@seg_endnotes[@@fn]=[] - @@seg_endnotes[@@fn] << @@seg_endnotes_array - @@seg_endnotes_array=[] if dob.ln==4 - @@fns_previous=@md.fns if dob.ln==4 and dob.name =~/^meta/ + and not @per.fn.to_s.empty? + @per.seg_endnotes[@per.fn]=[] + @per.seg_endnotes[@per.fn] << @per.seg_endnotes_array + @per.seg_endnotes_array=[] if dob.ln==4 end if (dob.is==:heading \ || dob.is==:heading_insert) \ && dob.ln==4 #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs - @@seg_subtoc[@@fn]=@@seg_subtoc_array - @@seg_subtoc_array=[] + @per.seg_subtoc[@per.fn]=@per.seg_subtoc_array + @per.seg_subtoc_array=[] if dob.name \ and dob.obj - @@fn=dob.name + @per.fn=dob.name else if dob.name =~/\S+/ - @@fn=dob.name - else @@fn='' + @per.fn=dob.name + else @per.fn='' end end end @@ -666,7 +664,7 @@ module SiSU_HTML_Seg format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) subtoc=format_seg.subtoc_lev7 #keep and make available, this is the subtoc end - @@seg_subtoc_array << subtoc + @per.seg_subtoc_array << subtoc end if @md.flag_auto_endnotes if (dob.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+\s*') #% creation of separate end segment/page of all endnotes referenced back to reference segment @@ -703,8 +703,8 @@ module SiSU_HTML_Seg endnote_part_b=note_match_seg[m,2] txt_obj={ endnote_part_a: endnote_part_a, endnote_part_b: endnote_part_b } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) - note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408 - @@seg[:endnote_all] << note_match_all_seg + note_match_all_seg=format_seg.endnote_seg_body(@per.fn) #BUG WATCH 200408 + @per.endnote_all << note_match_all_seg end dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') end -- cgit v1.2.3