diff options
Diffstat (limited to 'lib/sisu/v3dv/epub_segments.rb')
-rw-r--r-- | lib/sisu/v3dv/epub_segments.rb | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/lib/sisu/v3dv/epub_segments.rb b/lib/sisu/v3dv/epub_segments.rb index 5545dc23..1119d8c8 100644 --- a/lib/sisu/v3dv/epub_segments.rb +++ b/lib/sisu/v3dv/epub_segments.rb @@ -60,7 +60,7 @@ module SiSU_EPUB_Seg require_relative 'shared_xhtml' # shared_xhtml.rb require_relative 'epub' # epub.rb require_relative 'shared_metadata' # shared_metadata.rb - class SegOutput + class Output def initialize(md,outputfile,seg,minitoc,type='') @md,@output_epub_cont_seg,@seg,@minitoc,@type=md,outputfile,seg,minitoc,type end @@ -114,11 +114,10 @@ WOK filename_seg << @seg[:headings] << @seg[:main] << "\n</div>\n" end filename_seg << @seg[:tail] << @seg[:nav] << @seg[:close] - filename_seg.flatten!.compact! + filename_seg=filename_seg.flatten.compact #watch filename_seg.each do |str| unless str =~/\A\s*\Z/ - str.strip! - @output_epub_cont_seg << str + @output_epub_cont_seg << str.strip end end @output_epub_cont_seg.close @@ -149,7 +148,7 @@ WOK @minitoc=SiSU_EPUB::Source::Toc.new(@md,@data).minitoc data=get_subtoc_endnotes(@data) data=articles(data) - Seg.new.cleanup # (((( added )))) + SiSU_EPUB_Seg::Seg.new.cleanup # (((( added )))) #### (((( END )))) #### rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure @@ -187,10 +186,10 @@ WOK # #while dob.obj =~/href="#{Xx[:segment]}#+(\S+?)"/ # # m=$1 # # if map_nametags[m][:segname] - # # dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#{map_nametags[m][:segname]}#{Sfx[:html]}#\\1"}) + # # dob.obj=dob.obj.sub(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#{map_nametags[m][:segname]}#{Sfx[:html]}#\\1"}) # # else # # p "NOT FOUND name_tags: #{m}" - # # dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#\\1"}) # not satisfactory + # # dob.obj=dob.obj.sub(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#\\1"}) # not satisfactory # # end # #end #end @@ -237,32 +236,32 @@ WOK || dob.is=='heading_insert') \ and dob.ln==4 if tracking != 0 - Seg.new(@md).tail + SiSU_EPUB_Seg::Seg.new(@md).tail segfilename="#{dir_epub_cont}/#{@@seg_name_xhtml[tracking-1]}#{Sfx[:epub_xhtml]}" output_epub_cont_seg=File.new(segfilename,'w') if @@seg_name_xhtml[tracking-1] if dob.is=='heading' \ or @@seg_name_xhtml[tracking-1] !~/endnotes|book_index|metadata/ - SegOutput.new(@md,output_epub_cont_seg,@@seg,@minitoc).output + SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,@minitoc).output elsif dob.is=='heading_insert' if @@seg_name_xhtml[tracking-1]=='endnotes' - SegOutput.new(@md,output_epub_cont_seg,@@seg,@minitoc,'endnotes').output + SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'endnotes').output elsif @@seg_name_xhtml[tracking-1]=='book_index' - SegOutput.new(@md,output_epub_cont_seg,@@seg,@minitoc,'idx').output + SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'idx').output @@seg[:idx]=[] elsif @@seg_name_xhtml[tracking-1]=='metadata' # navigation bug FIX - SegOutput.new(@md,output_epub_cont_seg,@@seg,@minitoc,'metadata').output + SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'metadata').output else puts "#{__FILE__}::#{__LINE__}" end else puts "#{__FILE__}::#{__LINE__}" end - Seg.new.reinitialise + SiSU_EPUB_Seg::Seg.new.reinitialise heading_art(dob) head(dob) if @@seg_name_xhtml[tracking]=='sisu_manifest' # this is for manifest, includes navigation bug segfilename="#{dir_epub_cont}/#{@@seg_name_xhtml[tracking]}#{Sfx[:epub_xhtml]}" output_epub_cont_seg=File.new(segfilename,'w') - SegOutput.new(@md,output_epub_cont_seg,@@seg,@minitoc,'sisu_manifest').output - Seg.new.reinitialise #BUG navigation bug with items following metadata, and occurring before manifest, this becomes a bug ... work area for book index, FIX + SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'sisu_manifest').output + SiSU_EPUB_Seg::Seg.new.reinitialise #BUG navigation bug with items following metadata, and occurring before manifest, this becomes a bug ... work area for book index, FIX end #@output_epub_cont_seg.close #%(((( EOF )))) --> end @@ -329,7 +328,7 @@ WOK txt_obj={ txt: @@heading1, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading1.gsub(clean,'') - @@heading1.gsub!(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') + @@heading1=@@heading1.gsub(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') end if @@is2==1 heading2=@@heading2 @@ -340,7 +339,7 @@ WOK txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading2.gsub(clean,'') - @@heading2.gsub!(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') + @@heading2=@@heading2.gsub(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') end if @@is3==1 heading3=@@heading3 @@ -351,7 +350,7 @@ WOK txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading3.gsub(clean,'') - @@heading3.gsub!(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') + @@heading3=@@heading3.gsub(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') end if @@is4==1 heading4=@@heading4 @@ -413,7 +412,7 @@ WOK sto.break end if @md.flag_separate_endnotes # may need to revisit, check - dob.obj.gsub!(/"\s+href="#note_ref(\d+)">/,%{" href=\"endnotes#{Sfx[:epub_xhtml]}#note_ref\\1">}) #endnote- twice #removed file type + dob.obj=dob.obj.gsub(/"\s+href="#note_ref(\d+)">/,%{" href=\"endnotes#{Sfx[:epub_xhtml]}#note_ref\\1">}) #endnote- twice #removed file type end if dob.is =~/heading|para/ \ and (not dob.ocn or dob.ocn.to_s.empty?) @@ -464,7 +463,7 @@ WOK end def get_subtoc_endnotes(data) #get endnotes & sub-table of contents subtoc data.each do |dob| - dob.obj.gsub!(/<a name=\"h\d.*?\">(.+?)<\/a>/mi,'\1') + 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') \ @@ -516,7 +515,7 @@ WOK if dob.obj=~/#{Mx[:en_b_o]}#{pls}\d+\s.+?#{Mx[:en_b_c]}/m endnote_array << dob.obj.scan(/#{Mx[:en_b_o]}#{pls}\d+\s.+?#{Mx[:en_b_c]}/m) end - endnote_array.flatten! #.compact! #check compacting + endnote_array=endnote_array.flatten #.compact #check compacting endnote_array.each do |note| note_match=note.dup note_match_seg=note.dup @@ -541,7 +540,7 @@ WOK note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408 @@seg[:endnote_all] << note_match_all_seg end - dob.obj.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') end end end |