d: html, segments, reorganize, introduce new file
authorRalph Amissah <ralph@amissah.com>
Fri, 21 Nov 2014 04:03:24 +0000 (23:03 -0500)
committerRalph Amissah <ralph@amissah.com>
Mon, 8 Dec 2014 05:18:16 +0000 (00:18 -0500)
data/doc/sisu/CHANGELOG_v6
lib/sisu/develop/html.rb
lib/sisu/develop/html_format.rb
lib/sisu/develop/html_manifest.rb
lib/sisu/develop/html_persist.rb [new file with mode: 0644]
lib/sisu/develop/html_segments.rb

index 4299810c4c1f7403d2769a1cd595316b6f7de035..6a45a761da4869b3488346cfd4400a882b22b8a0 100644 (file)
@@ -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)
index 1f128afcb441665d36c71bdc79ecfbc553b566b8..737d532e423f5e00a579b0c648bb210776f16131 100644 (file)
@@ -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
index b69c5d86f05bf46ab7d7895d49885ee68f846515..5d7a4a7dcfc27348954675981e80a27e4cbb6c4d 100644 (file)
@@ -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?) ? '' : %{<a href="##{@ocn_html_identifier}#{@ocn}">}
+      (@ocn==nil || @ocn.empty?) \
+      ? '' : %{<a href="##{@ocn_html_identifier}#{@ocn}">}
     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
 <head>
   <meta charset="utf-8">
   <title>
-    #{@md.html_title}
+    #{@md.title.full}
   </title>
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 #{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}"
       %{<table summary="segment hidden control pre" width="100%" border="0" cellpadding="0" bgcolor=#{the_color.grey_pale} align="center">
@@ -671,12 +674,12 @@ WOK
   </a>
 </td>}
       pre=%{<td align="center" bgcolor=#{the_color.band1}>
-  <a href="#{@seg_name_html[@seg_name_html_tracker-use]}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top">
+  <a href="#{@per.seg_name_x[@per.seg_name_x_tracker-use]}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top">
     #{png_nav.pre}
   </a>
 </td>} if f_pre==true
       nxt=%{<td align="center" bgcolor=#{the_color.band1}>
-  <a href="#{@seg_name_html[@seg_name_html_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top">
+  <a href="#{@per.seg_name_x[@per.seg_name_x_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top">
     #{png_nav.nxt}
   </a>
 </td>} if f_nxt==true
@@ -721,23 +724,6 @@ WOK
       else ''
       end
     end
-    def navigation_table
-      %{<table summary="navigation segment table" width=#{the_width.table1} border="0" bgcolor="white" cellpadding="0">
-<tr><th width="#{@@indent['leve_1']}" align="right">
-</td>
-<td valign="top">
-  <font size=2>}
-    end
-    def navigation_table1
-      %{<table summary="navigation segment table1" width=#{the_width.table1} border="0" cellpadding=#{the_table_cellpad_box} bgcolor=#{the_color.table1} align="left">
-<tr><td valign="top">
-  <font size="2">}
-    end
-    def navigation_table2
-      %{<table summary="navigation segment table2" width=#{the_width.table2} border="0" cellpadding=#{the_table_cellpad_box} bgcolor=#{the_color.table2} align="left">
-<tr><td valign="top">
-  <font size="2">}
-    end
     def credit
       %{
 <div class="main_column">
@@ -799,8 +785,8 @@ WOK
 <head>
   <meta charset="utf-8">
   <title>
-    #{@seg_name_html[@seg_name_html_tracker]} -
-    #{@md.html_title}
+    #{@per.seg_name_x[@per.seg_name_x_tracker]} -
+    #{@md.title.main}
   </title>
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
 #{rdf.metatag_html}
index fc07a4c70f534bf6e839f0e96cf3bfd7938dd396..3e61d29beab1bec9d45c32d8d64d358b4f47982f 100644 (file)
@@ -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 (file)
index 0000000..482a0c0
--- /dev/null
@@ -0,0 +1,237 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** html segment generation, processing
+
+** Author: Ralph Amissah
+  <ralph@amissah.com>
+  <ralph.amissah@gmail.com>
+
+** 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 <http://www.gnu.org/licenses/>.
+
+  If you have Internet connection, the latest version of the GPL should be
+  available at these locations:
+  <http://www.fsf.org/licensing/licenses/gpl.html>
+  <http://www.gnu.org/licenses/gpl.html>
+
+  <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+  * Standard SiSU markup syntax,
+  * Standard SiSU meta-markup syntax, and the
+  * Standard SiSU object citation numbering and system
+
+** Hompages:
+  <http://www.jus.uio.no/sisu>
+  <http://www.sisudoc.org>
+
+** Git
+  <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+  <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/develop/html_persist.rb;hb=HEAD>
+
+=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__
index 61bed7bfd2151d4b07a05fd9aee039a296d5b935..d6a76de65bf5ce2152860ddbc3d320fb3cb5938a 100644 (file)
 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<div class="#{@cl}">\n} \
-          << @seg[:endnote_all] \
+          << @per.endnote_all \
           << '</div>' # << '</div>'
         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<div class="#{@cl}">\n} \
-          << @seg[:idx] \
+          << @per.idx \
           << '</div>' # << '</div>'
         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<div class="#{@cl}">\n} \
           << metadata \
           << '</div>' # << '</div>'
@@ -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</div>\n"
           else
             filename_seg \
             << @minitoc \
-            << @seg[:main] \
+            << @per.main \
             << "\n</div>\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=%{<b>#{@md.author}</b>\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 \
         << '<br>' \
-        << 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(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/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(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/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(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/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(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/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<div class="#{@cl}">\n}
-          @@seg[:main] << dob_html
+          @per.main << %{\n<div class="#{@cl}">\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<div class="#{@cl}">\n<div class="endnote">\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<div class="#{@cl}">\n<div class="endnote">\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] << '</div>'
-        @@seg[:tail] << '</div>' #this div closes div class content
+        @per.tail << '</div>'
+        @per.tail << '</div>' #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 name=\"h\d.*?\">(.+?)<\/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*<a href="##{Mx[:note_ref]}[\d*+]+"/) \
@@ -676,10 +674,12 @@ module SiSU_HTML_Seg
               endnote_array << dob.obj.scan(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m)
             end
             if dob.obj=~/#{Mx[:en_b_o]}[*]\d+\s.+?#{Mx[:en_b_c]}/m
-              endnote_array << dob.obj.scan(/#{Mx[:en_b_o]}[*]\d+\s.+?#{Mx[:en_b_c]}/m)
+              endnote_array \
+              << dob.obj.scan(/#{Mx[:en_b_o]}[*]\d+\s.+?#{Mx[:en_b_c]}/m)
             end
             if dob.obj=~/#{Mx[:en_b_o]}[+]\d+\s.+?#{Mx[:en_b_c]}/m
-              endnote_array << dob.obj.scan(/#{Mx[:en_b_o]}[+]\d+\s.+?#{Mx[:en_b_c]}/m)
+              endnote_array \
+              << dob.obj.scan(/#{Mx[:en_b_o]}[+]\d+\s.+?#{Mx[:en_b_c]}/m)
             end
             endnote_array=endnote_array.flatten.compact #watch, check compacting
             endnote_array.each do |note|
@@ -694,7 +694,7 @@ module SiSU_HTML_Seg
                   format_seg.endnote_body_indent
                 else format_seg.endnote_body
                 end
-                @@seg_endnotes_array << note_match
+                @per.seg_endnotes_array << note_match
               end
               try.join('<br>')
               #% 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