diff options
Diffstat (limited to 'lib/sisu/develop/xhtml_epub2.rb')
-rw-r--r-- | lib/sisu/develop/xhtml_epub2.rb | 182 |
1 files changed, 91 insertions, 91 deletions
diff --git a/lib/sisu/develop/xhtml_epub2.rb b/lib/sisu/develop/xhtml_epub2.rb index edfb6e62..b595b00d 100644 --- a/lib/sisu/develop/xhtml_epub2.rb +++ b/lib/sisu/develop/xhtml_epub2.rb @@ -73,6 +73,7 @@ module SiSU_XHTML_EPUB2 require_relative 'xhtml_epub2_tune' # xhtml_epub2_tune.rb include SiSU_XHTML_EPUB2_Tune require_relative 'xhtml_epub2_concordance' # xhtml_epub2_concordance.rb + require_relative 'xhtml_epub2_persist' # xhtml_epub2_persist.rb class Source def initialize(opt) @opt=opt @@ -124,9 +125,9 @@ module SiSU_XHTML_EPUB2 SiSU_Env::FileOp.new(@md).mkdir.output.epub @tuned_file_array=SiSU_XHTML_EPUB2::Source::XHTML_Environment.new(@particulars).tuned_file_instructions data=@tuned_file_array - toc=SiSU_XHTML_EPUB2::Source::Toc.new(@md,data).songsheet + per=SiSU_XHTML_EPUB2::Source::Toc.new(@md,data).songsheet data=@tuned_file_array - SiSU_XHTML_EPUB2::Source::ScrollHeadAndSegToc.new(@md,toc).in_common #watch + SiSU_XHTML_EPUB2::Source::ScrollHeadAndSegToc.new(@md,per).in_common #watch SiSU_XHTML_EPUB2::Source::Seg.new(@md,data).songsheet SiSU_XHTML_EPUB2::Source::Output.new(@md).songsheet rescue @@ -144,11 +145,10 @@ module SiSU_XHTML_EPUB2 end end SiSU_Env::Clear.new(@opt.selections.str,@opt.fns).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_html,@@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 @@ -202,7 +202,6 @@ module SiSU_XHTML_EPUB2 end end class Toc - @@toc={ seg: [], seg_mini: [], scr: [], ncx: [], opf: [] } @@seg_url='' @@firstseg=nil def initialize(md=nil,data='') @@ -210,6 +209,7 @@ module SiSU_XHTML_EPUB2 @epub=SiSU_XHTML_EPUB2_Format::HeadInformation.new(@md) @tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]) if @md @make=SiSU_Env::ProcessingSettings.new(@md) + @per=SiSU_XHTML_EPUB2_Persist::PersistTOC.new end def songsheet #extracts toc for scroll & seg if (@md.opt.act[:verbose][:set]==:on \ @@ -222,19 +222,19 @@ module SiSU_XHTML_EPUB2 end toc=nil @@firstseg=nil - @@toc={ seg: [], seg_mini: [], scr: [], ncx: [], opf: [] } + 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 - @@toc[:ncx] << @epub.toc_ncx.open #epub ncx navmap - @@toc[:ncx] << @epub.toc_ncx.head_open << @epub.toc_ncx.head << @epub.toc_ncx.head_close - @@toc[:ncx] << @epub.toc_ncx.doc_title << @epub.toc_ncx.doc_author - @@toc[:ncx] << @epub.toc_ncx.navmap_open - @@toc[:opf] << @epub.metadata_opf.package_open - @@toc[:opf] << @epub.metadata_opf.metadata - @@toc[:opf] << @epub.metadata_opf.manifest_open - @@toc[:seg] << %{<div class="content">\n<div class="substance">} - @@toc[:scr] << %{<div class="content">\n<div class="substance">} + @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+/ @@ -261,24 +261,24 @@ module SiSU_XHTML_EPUB2 lv_name='section_a' + @s_a_no.to_s @nav_no+=1 @nav_no2=@nav_no - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[1] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[0] + @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? - @@toc[:ncx] << @epub.toc_ncx.navmap_sisu_toc(@nav_no) #epub ncx navmap, toc + @per.ncx << @epub.toc_ncx.navmap_sisu_toc(@nav_no) #epub ncx navmap, toc @nav_no+=1 @level_a_first_occurrence=false end - @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc + @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) @@ -288,17 +288,17 @@ module SiSU_XHTML_EPUB2 lv_name='section_b' + @s_b_no.to_s @nav_no+=1 @nav_no2=@nav_no - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[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] + @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) - @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc + @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) @@ -308,16 +308,16 @@ module SiSU_XHTML_EPUB2 lv_name='section_c' + @s_c_no.to_s @nav_no+=1 @nav_no2=@nav_no - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2] + @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) - @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc + @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) @@ -327,15 +327,15 @@ module SiSU_XHTML_EPUB2 lv_name='section_d' + @s_d_no.to_s @nav_no+=1 @nav_no3=@nav_no - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3] + @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) - @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc + @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) @@ -345,13 +345,13 @@ module SiSU_XHTML_EPUB2 lv_name=dob_toc.name @nav_no+=1 @dob_name=dob.name - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4] + @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 - @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc + @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) @@ -361,12 +361,12 @@ module SiSU_XHTML_EPUB2 hashtag='#o' + dob_toc.ocn.to_s lv_name=@dob_name @nav_no+=1 - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5] + @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 - @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc + @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) @@ -376,11 +376,11 @@ module SiSU_XHTML_EPUB2 hashtag='#o' + dob_toc.ocn.to_s lv_name=@dob_name @nav_no+=1 - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6] + @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 - @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc + @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) @@ -390,9 +390,9 @@ module SiSU_XHTML_EPUB2 hashtag='#o' + dob_toc.ocn.to_s lv_name=@dob_name @nav_no+=1 - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7] + @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7] @ncxo[7]=true - @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc + @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) @@ -409,8 +409,8 @@ module SiSU_XHTML_EPUB2 end if toc begin - @@toc[:seg] << toc[:seg] - @@toc[:scr] << toc[:seg] + @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__ @@ -419,28 +419,28 @@ module SiSU_XHTML_EPUB2 end end end - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[1] - @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[0] + @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]) - @@toc[:seg] << "</div>\n</div>" - @@toc[:scr] << "</div>\n</div>" - @@toc[:ncx] << @epub.toc_ncx.navmap_close - @@toc[:ncx] << @epub.toc_ncx.close - @@toc[:opf] << md_opf_a_content << @epub.metadata_opf.manifest_close - @@toc[:opf] << @epub.metadata_opf.spine_open << md_opf_a_spine << @epub.metadata_opf.spine_close - @@toc[:opf] << @epub.metadata_opf.guide_open << md_opf_a_guide << @epub.metadata_opf.guide_close - @@toc[:opf] << @epub.metadata_opf.package_close - @@toc[:opf]=@@toc[:opf].flatten - SiSU_XHTML_EPUB2::Source::Output.new(@md,@@toc[:opf]).epub_metadata_opf - SiSU_XHTML_EPUB2::Source::Output.new(@md,@@toc[:ncx]).epub_toc_ncx + @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 - @@toc + @per end protected def level_0 @@ -454,7 +454,7 @@ module SiSU_XHTML_EPUB2 toc[:seg]=format_toc.lev1 title=if dob.ocn ==0 then linkname else - @@toc[:scr] << '<br />' + @per.scr << '<br />' link=(dob.ln) \ ? dob.ln : '' @@ -490,7 +490,7 @@ module SiSU_XHTML_EPUB2 else linkname end else - @@toc[:scr] << '<br />' + @per.scr << '<br />' link=(dob.ln) \ ? dob.ln : '' @@ -636,8 +636,8 @@ module SiSU_XHTML_EPUB2 end end class ScrollHeadAndSegToc < Toc - def initialize(md='',toc='',links_guide_toc='') - @md,@toc,@links_guide_toc=md,toc,links_guide_toc + def initialize(md='',per='',links_guide_toc='') + @md,@per,@links_guide_toc=md,per,links_guide_toc end def in_common toc_shared=[] @@ -699,9 +699,9 @@ module SiSU_XHTML_EPUB2 toc_shared << prefix_b end #Table of Contents added/appended here - toc_shared << @toc[:scr] + toc_shared << @per.scr segtoc << @links_guide_toc - segtoc << @toc[:seg] + segtoc << @per.seg if defined? @md.rights.all \ and @md.rights.all segtoc << rights @@ -716,7 +716,7 @@ module SiSU_XHTML_EPUB2 SiSU_XHTML_EPUB2::Source::Output.new(@md).make_cover_image SiSU_XHTML_EPUB2::Source::Output.new(@md,segtoc).make_segtoc segtoc=[] - @toc[:scr],@toc[:seg]=[],[] + @per.scr,@per.seg=[],[] toc_shared end end |