d: persist, address garbage collection issue, bug, fix
authorRalph Amissah <ralph@amissah.com>
Thu, 11 Dec 2014 23:58:50 +0000 (18:58 -0500)
committerRalph Amissah <ralph@amissah.com>
Thu, 11 Dec 2014 23:58:50 +0000 (18:58 -0500)
* related to code related changes (re: "persistence") in
  recent reorganization of txt, html, epub, xmls etc.

data/doc/sisu/CHANGELOG_v6
lib/sisu/develop/ao.rb
lib/sisu/develop/html_segments.rb
lib/sisu/develop/xhtml.rb
lib/sisu/develop/xhtml_epub2.rb
lib/sisu/develop/xhtml_epub2_segments.rb
lib/sisu/develop/xml_dom.rb
lib/sisu/develop/xml_odf_odt.rb
lib/sisu/develop/xml_sax.rb

index 9e1a1afab0b21eefcfebdc0dfa4cf49a9d7a4b23..5f7fd012547b4fa3d229d271c3c97f97438d0d3f 100644 (file)
@@ -67,16 +67,15 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.4.0.orig.tar.xz
 
   * ao, rearrange, introduce new file
 
-  * txt outputs, reorganize, introduce new files
+  * reorganize, introduce new file(s)
+    * txt outputs
+    * html segments
+    * epub
+    * xmls
+  * address related garbage collection issue
 
   * orgmode, add orgmode structure output to txts
 
-  * html, segments, reorganize, introduce new file
-
-  * epub, reorganize, introduce new file
-
-  * xmls, reorganize, introduce new file
-
   * cgi, search form, html ref, remove leading 'o' ocn, bugfix
     in html (on use of html5), removed leading 'o' before ocn, not
     reflected in generated cgi, sample search form, so, does not
index 585192b0407902a58446b8a78e0496aa00adb619..747c987e4f6640b2fc19052e573afdf9f688c62d 100644 (file)
@@ -119,6 +119,7 @@ module SiSU_AO
           __LINE__.to_s + ':' + __FILE__
         end
       ensure
+        SiSU_AO_Persist::Persist.new.persist_init
         SiSU_AO::Instantiate.new
       end
     end
index d6a76de65bf5ce2152860ddbc3d320fb3cb5938a..65bd2d643bddb277b7139769b7ec0b2ff250ef94 100644 (file)
@@ -199,7 +199,6 @@ module SiSU_HTML_Seg
     def songsheet
       begin
         @minitoc=SiSU_HTML::Source::Toc.new(@md,@data).minitoc
-        SiSU_HTML_Persist::Persist.new.persist_init
         @per=SiSU_HTML_Persist::Persist.new
         data=get_subtoc_endnotes(@data,@per)
         data=articles(data,@per)
@@ -210,6 +209,7 @@ module SiSU_HTML_Seg
           __LINE__.to_s + ':' + __FILE__
         end
       ensure
+        SiSU_HTML_Persist::Persist.new.persist_init
         @@seg_name=@per.seg_name=[]
       end
     end
index 9e06d7b268dae4fefa6b56dc5f656570c3947b47..d24a568e23b2947fd42aeba5dcd7aab784dd58be 100644 (file)
@@ -153,10 +153,14 @@ module SiSU_XHTML
         @per=SiSU_XML_Persist::Persist.new
       end
       def songsheet
-        pre
-        @data=markup(@ao_array)
-        post
-        publish
+        begin
+          pre
+          @data=markup(@ao_array)
+          post
+          publish
+        ensure
+          SiSU_XML_Persist::Persist.new.persist_init
+        end
       end
     protected
       def embedded_endnotes(dob='')
index b595b00dbb19a56eabfc75285f3613f78400db99..0c4e62454073b830ff25b5488a8b5b0c56394dab 100644 (file)
@@ -212,235 +212,239 @@ module SiSU_XHTML_EPUB2
         @per=SiSU_XHTML_EPUB2_Persist::PersistTOC.new
       end
       def songsheet #extracts toc for scroll & seg
-        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],
-            'Toc'
-          ).txt_grey
-        end
-        toc=nil
-        @@firstseg=nil
-        SiSU_XHTML_EPUB2_Persist::PersistTOC.new.persist_init
-        md_opf_a_content,md_opf_a_spine,md_opf_a_guide=[],[],[]
-        @nav_no=0
-        @s_a_no,@s_b_no,@s_c_no,@s_d_no,@lv5_no,@lv6_no=0,0,0,0,0,0
-        @per.ncx << @epub.toc_ncx.open #epub ncx navmap
-        @per.ncx << @epub.toc_ncx.head_open << @epub.toc_ncx.head << @epub.toc_ncx.head_close
-        @per.ncx << @epub.toc_ncx.doc_title << @epub.toc_ncx.doc_author
-        @per.ncx << @epub.toc_ncx.navmap_open
-        @per.opf << @epub.metadata_opf.package_open
-        @per.opf << @epub.metadata_opf.metadata
-        @per.opf << @epub.metadata_opf.manifest_open
-        @per.seg << %{<div class="content">\n<div class="substance">}
-        @per.scr << %{<div class="content">\n<div class="substance">}
-        if defined? @md.make.cover_image \
-        and @md.make.cover_image.is_a?(Hash) \
-        and @md.make.cover_image[:cover] =~/\S+/
-          md_opf_a_content << @epub.metadata_opf.manifest_cover_image_information(@md)
-          md_opf_a_spine << @epub.metadata_opf.spine_cover_image
-          md_opf_a_guide << @epub.metadata_opf.guide_cover_image
-        end
-        md_opf_a_content << @epub.metadata_opf.manifest_content_sisu_toc
-        if @make.build.toc?
-          md_opf_a_spine << @epub.metadata_opf.spine_sisu_toc
-          md_opf_a_guide << @epub.metadata_opf.guide_sisu_toc
-        end
-        @ncxo=[false,false,false,false,false,false,false]
-        @dob_toc2,@dob_toc3=nil,nil
-        @ncx_cls=[]
-        @level_a_first_occurrence=true
-        @data.each do |dob|
-          if dob.is==:heading \
-          || dob.is==:heading_insert
-            dob_toc=dob.dup
-            toc=case dob_toc.ln
-            when 0
-              @s_a_no +=1
-              lv_name='section_a' + @s_a_no.to_s
-              @nav_no+=1
-              @nav_no2=@nav_no
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[2]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[1]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[0]
-              @ncxo[0],@ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
-                true,  false,   false,   false,   false,   false,   false,   false
-              @epub.sections(dob_toc,lv_name)
-              if @level_a_first_occurrence \
-              && @make.build.toc?
-                @per.ncx << @epub.toc_ncx.navmap_sisu_toc(@nav_no) #epub ncx navmap, toc
+        begin
+          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],
+              'Toc'
+            ).txt_grey
+          end
+          toc=nil
+          @@firstseg=nil
+          SiSU_XHTML_EPUB2_Persist::PersistTOC.new.persist_init
+          md_opf_a_content,md_opf_a_spine,md_opf_a_guide=[],[],[]
+          @nav_no=0
+          @s_a_no,@s_b_no,@s_c_no,@s_d_no,@lv5_no,@lv6_no=0,0,0,0,0,0
+          @per.ncx << @epub.toc_ncx.open #epub ncx navmap
+          @per.ncx << @epub.toc_ncx.head_open << @epub.toc_ncx.head << @epub.toc_ncx.head_close
+          @per.ncx << @epub.toc_ncx.doc_title << @epub.toc_ncx.doc_author
+          @per.ncx << @epub.toc_ncx.navmap_open
+          @per.opf << @epub.metadata_opf.package_open
+          @per.opf << @epub.metadata_opf.metadata
+          @per.opf << @epub.metadata_opf.manifest_open
+          @per.seg << %{<div class="content">\n<div class="substance">}
+          @per.scr << %{<div class="content">\n<div class="substance">}
+          if defined? @md.make.cover_image \
+          and @md.make.cover_image.is_a?(Hash) \
+          and @md.make.cover_image[:cover] =~/\S+/
+            md_opf_a_content << @epub.metadata_opf.manifest_cover_image_information(@md)
+            md_opf_a_spine << @epub.metadata_opf.spine_cover_image
+            md_opf_a_guide << @epub.metadata_opf.guide_cover_image
+          end
+          md_opf_a_content << @epub.metadata_opf.manifest_content_sisu_toc
+          if @make.build.toc?
+            md_opf_a_spine << @epub.metadata_opf.spine_sisu_toc
+            md_opf_a_guide << @epub.metadata_opf.guide_sisu_toc
+          end
+          @ncxo=[false,false,false,false,false,false,false]
+          @dob_toc2,@dob_toc3=nil,nil
+          @ncx_cls=[]
+          @level_a_first_occurrence=true
+          @data.each do |dob|
+            if dob.is==:heading \
+            || dob.is==:heading_insert
+              dob_toc=dob.dup
+              toc=case dob_toc.ln
+              when 0
+                @s_a_no +=1
+                lv_name='section_a' + @s_a_no.to_s
+                @nav_no+=1
+                @nav_no2=@nav_no
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[2]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[1]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[0]
+                @ncxo[0],@ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
+                  true,  false,   false,   false,   false,   false,   false,   false
+                @epub.sections(dob_toc,lv_name)
+                if @level_a_first_occurrence \
+                && @make.build.toc?
+                  @per.ncx << @epub.toc_ncx.navmap_sisu_toc(@nav_no) #epub ncx navmap, toc
+                  @nav_no+=1
+                  @level_a_first_occurrence=false
+                end
+                @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+                md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+                md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+                md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
+                SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_0
+              when 1
+                @s_b_no +=1
+                lv_name='section_b' + @s_b_no.to_s
+                @nav_no+=1
+                @nav_no2=@nav_no
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[2]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[1]
+                @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
+                  true,  false,   false,   false,   false,   false,   false
+                @epub.sections(dob_toc,lv_name)
+                @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+                md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+                md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+                md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
+                SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_1
+              when 2
+                @s_c_no +=1
+                lv_name='section_c' + @s_c_no.to_s
+                @nav_no+=1
+                @nav_no2=@nav_no
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[2]
+                @ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
+                  true,  false,   false,   false,   false,   false
+                @epub.sections(dob_toc,lv_name)
+                @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+                md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+                md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+                md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
+                SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_2
+              when 3
+                @s_d_no +=1
+                lv_name='section_d' + @s_d_no.to_s
+                @nav_no+=1
+                @nav_no3=@nav_no
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
+                @ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
+                  true,  false,   false,   false,   false
+                @epub.sections(dob_toc,lv_name)
+                @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+                md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+                md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+                md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
+                SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_3
+              when 4
+                @ncx_cls=[]
+                lv_name=dob_toc.name
                 @nav_no+=1
-                @level_a_first_occurrence=false
+                @dob_name=dob.name
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
+                @ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
+                  true,  false,   false,   false
+                @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+                md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+                md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+                md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
+                SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_4
+              when 5
+                @ncx_cls=[]
+                hashtag='#o' + dob_toc.ocn.to_s
+                lv_name=@dob_name
+                @nav_no+=1
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+                @ncxo[5],@ncxo[6],@ncxo[7]=
+                  true,  false, false
+                @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
+                md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
+                md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
+                md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
+                SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_5
+              when 6
+                @ncx_cls=[]
+                hashtag='#o' + dob_toc.ocn.to_s
+                lv_name=@dob_name
+                @nav_no+=1
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+                @ncxo[6],@ncxo[7]=
+                  true,  false
+                @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
+                md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
+                md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
+                md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
+                SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_6
+              when 7
+                @ncx_cls=[]
+                hashtag='#o' + dob_toc.ocn.to_s
+                lv_name=@dob_name
+                @nav_no+=1
+                @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+                @ncxo[7]=true
+                @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
+                md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
+                md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
+                md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
+                SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_7
+              else nil
               end
-              @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
-              md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
-              md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
-              md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
-              SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_0
-            when 1
-              @s_b_no +=1
-              lv_name='section_b' + @s_b_no.to_s
-              @nav_no+=1
-              @nav_no2=@nav_no
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[2]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[1]
-              @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
-                true,  false,   false,   false,   false,   false,   false
-              @epub.sections(dob_toc,lv_name)
-              @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
-              md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
-              md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
-              md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
-              SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_1
-            when 2
-              @s_c_no +=1
-              lv_name='section_c' + @s_c_no.to_s
-              @nav_no+=1
-              @nav_no2=@nav_no
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[2]
-              @ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
-                true,  false,   false,   false,   false,   false
-              @epub.sections(dob_toc,lv_name)
-              @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
-              md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
-              md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
-              md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
-              SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_2
-            when 3
-              @s_d_no +=1
-              lv_name='section_d' + @s_d_no.to_s
-              @nav_no+=1
-              @nav_no3=@nav_no
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
-              @ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
-                true,  false,   false,   false,   false
-              @epub.sections(dob_toc,lv_name)
-              @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
-              md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
-              md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
-              md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
-              SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_3
-            when 4
-              @ncx_cls=[]
-              lv_name=dob_toc.name
-              @nav_no+=1
-              @dob_name=dob.name
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
-              @ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
-                true,  false,   false,   false
-              @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
-              md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
-              md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
-              md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
-              SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_4
-            when 5
-              @ncx_cls=[]
-              hashtag='#o' + dob_toc.ocn.to_s
-              lv_name=@dob_name
-              @nav_no+=1
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
-              @ncxo[5],@ncxo[6],@ncxo[7]=
-                true,  false, false
-              @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
-              md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
-              md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
-              md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
-              SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_5
-            when 6
-              @ncx_cls=[]
-              hashtag='#o' + dob_toc.ocn.to_s
-              lv_name=@dob_name
-              @nav_no+=1
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
-              @ncxo[6],@ncxo[7]=
-                true,  false
-              @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
-              md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
-              md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
-              md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
-              SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_6
-            when 7
-              @ncx_cls=[]
-              hashtag='#o' + dob_toc.ocn.to_s
-              lv_name=@dob_name
-              @nav_no+=1
-              @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
-              @ncxo[7]=true
-              @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
-              md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
-              md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
-              md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
-              SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_7
-            else nil
-            end
-            toc.each do |k,d|
-              d.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
-            end if toc
-            if @@firstseg.nil? \
-            and dob.ln==4 \
-            and dob.name =~/\S+/
-              @@firstseg=dob.name
-            end
-            if toc
-              begin
-                @per.seg << toc[:seg]
-                @per.scr << toc[:seg]
-              rescue
-                SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
-                  __LINE__.to_s + ':' + __FILE__
+              toc.each do |k,d|
+                d.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
+              end if toc
+              if @@firstseg.nil? \
+              and dob.ln==4 \
+              and dob.name =~/\S+/
+                @@firstseg=dob.name
+              end
+              if toc
+                begin
+                  @per.seg << toc[:seg]
+                  @per.scr << toc[:seg]
+                rescue
+                  SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
+                    __LINE__.to_s + ':' + __FILE__
+                  end
                 end
               end
             end
           end
+          @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+          @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+          @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
+          @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
+          @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[2]
+          @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[1]
+          @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[0]
+          @ncxo[0],@ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=false,false,false,false,false,false,false
+          md_opf_a_content << @epub.metadata_opf.manifest_images(@md.ec[:image])
+          @per.seg << "</div>\n</div>"
+          @per.scr << "</div>\n</div>"
+          @per.ncx << @epub.toc_ncx.navmap_close
+          @per.ncx << @epub.toc_ncx.close
+          @per.opf << md_opf_a_content << @epub.metadata_opf.manifest_close
+          @per.opf << @epub.metadata_opf.spine_open << md_opf_a_spine << @epub.metadata_opf.spine_close
+          @per.opf << @epub.metadata_opf.guide_open << md_opf_a_guide << @epub.metadata_opf.guide_close
+          @per.opf << @epub.metadata_opf.package_close
+          @per.opf=@per.opf.flatten
+          SiSU_XHTML_EPUB2::Source::Output.new(@md,@per.opf).epub_metadata_opf
+          SiSU_XHTML_EPUB2::Source::Output.new(@md,@per.ncx).epub_toc_ncx
+          @md.firstseg=@@firstseg
+          @per
+        ensure
+          SiSU_XHTML_EPUB2_Persist::Persist.new.persist_init
         end
-        @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
-        @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
-        @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
-        @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
-        @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[2]
-        @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[1]
-        @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[0]
-        @ncxo[0],@ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=false,false,false,false,false,false,false
-        md_opf_a_content << @epub.metadata_opf.manifest_images(@md.ec[:image])
-        @per.seg << "</div>\n</div>"
-        @per.scr << "</div>\n</div>"
-        @per.ncx << @epub.toc_ncx.navmap_close
-        @per.ncx << @epub.toc_ncx.close
-        @per.opf << md_opf_a_content << @epub.metadata_opf.manifest_close
-        @per.opf << @epub.metadata_opf.spine_open << md_opf_a_spine << @epub.metadata_opf.spine_close
-        @per.opf << @epub.metadata_opf.guide_open << md_opf_a_guide << @epub.metadata_opf.guide_close
-        @per.opf << @epub.metadata_opf.package_close
-        @per.opf=@per.opf.flatten
-        SiSU_XHTML_EPUB2::Source::Output.new(@md,@per.opf).epub_metadata_opf
-        SiSU_XHTML_EPUB2::Source::Output.new(@md,@per.ncx).epub_toc_ncx
-        @md.firstseg=@@firstseg
-        @per
       end
     protected
       def level_0
index b3ce33b0d569fdc2eb63c0c1455d4e4c6aff45c2..436cf8452eda778abf56b1127e58697923333b11 100644 (file)
@@ -164,7 +164,6 @@ WOK
     end
     def songsheet
       begin
-        SiSU_XHTML_EPUB2_Persist::Persist.new.persist_init
         data=get_subtoc_endnotes(@data,@per)
         data=articles(data,@per)
         SiSU_XHTML_EPUB2_Seg::Seg.new.cleanup(@md,@per) # (((( added ))))
@@ -174,6 +173,7 @@ WOK
           __LINE__.to_s + ':' + __FILE__
         end
       ensure
+        SiSU_XHTML_EPUB2_Persist::Persist.new.persist_init
         @@seg_name=@per.seg_name=[]
       end
     end
index b3d3adde316c9e71a43115cbec10923ac06d2c88..199faed54465dd3ffa8af72cbf1c6073ac6f6df7 100644 (file)
@@ -167,10 +167,14 @@ module SiSU_XML_DOM
         @per=SiSU_XML_Persist::Persist.new
       end
       def songsheet
-        pre
-        @data=markup(@ao_arr)
-        post
-        publish
+        begin
+          pre
+          @data=markup(@ao_arr)
+          post
+          publish
+        ensure
+          SiSU_XML_Persist::Persist.new.persist_init
+        end
       end
     protected
       def xml_markup(dob='')
index 16a77e7a0cdd0945b73b30ba10576cdf7b857cd1..85a85ddd2d945687aa7b8f2e878916ac643de8e7 100644 (file)
@@ -145,6 +145,7 @@ module SiSU_XML_ODF_ODT
           @data=markup(@ao_array)
           publish
         ensure
+          SiSU_XML_Persist::Persist.new.persist_init
           unless (@md.opt.act[:verbose_plus][:set]==:on \
           || @md.opt.act[:maintenance][:set]==:on)
             if @env.processing_path.odt =~/od[ft]/
index 81e2423d979a1af60023e8a834199fbd7777450b..8d552f921f98631557557f6c2f304cd8982c6d01 100644 (file)
@@ -168,10 +168,14 @@ module SiSU_XML_SAX
         @per=SiSU_XML_Persist::Persist.new
       end
       def songsheet
-        pre
-        @data=markup(@ao_arr)
-        post
-        publish
+        begin
+          pre
+          @data=markup(@ao_arr)
+          post
+          publish
+        ensure
+          SiSU_XML_Persist::Persist.new.persist_init
+        end
       end
     protected
       def embedded_endnotes(dob='')