aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3dv/epub_segments.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3dv/epub_segments.rb')
-rw-r--r--lib/sisu/v3dv/epub_segments.rb128
1 files changed, 54 insertions, 74 deletions
diff --git a/lib/sisu/v3dv/epub_segments.rb b/lib/sisu/v3dv/epub_segments.rb
index 1119d8c8..55c6c1f9 100644
--- a/lib/sisu/v3dv/epub_segments.rb
+++ b/lib/sisu/v3dv/epub_segments.rb
@@ -69,26 +69,19 @@ module SiSU_EPUB_Seg
filename_seg=[]
filename_seg << @seg[:title] << @seg[:nav]
if @type=='endnotes'
- @seg[:headings]=[]
- format_head_seg=SiSU_EPUB_Format::HeadSeg.new(@md)
- @seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author)
+ @seg[:headings]=[] #watch
txt_obj={ txt: 'Endnotes', ocn_display: ''}
format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj)
@seg[:headings] << format_seg.title_heading1
filename_seg << @seg[:heading_endnotes] << @seg[:headings] << %{\n<div class="content">\n} << @seg[:endnote_all] << '</div>'
elsif @type=='idx'
@seg[:headings]=[]
- format_head_seg=SiSU_EPUB_Format::HeadSeg.new(@md)
- @seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author)
- txt_obj={ txt: 'Index', ocn_display: ''}
format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj)
@seg[:headings] << format_seg.title_heading1
filename_seg << @seg[:heading_idx] << @seg[:headings] << %{\n<div class="content">\n} << @seg[:idx] << '</div>'
elsif @type=='metadata'
metadata=SiSU_Metadata::Summary.new(@md).xhtml_display.metadata
@seg[:headings]=[]
- format_head_seg=SiSU_EPUB_Format::HeadSeg.new(@md)
- @seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author)
txt_obj={ txt: 'Metadata', ocn_display: ''}
format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj)
@seg[:headings] << format_seg.title_heading1
@@ -104,8 +97,6 @@ WOK
else ''
end
@seg[:headings]=[]
- format_head_seg=SiSU_EPUB_Format::HeadSeg.new(@md)
- @seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author)
txt_obj={ txt: 'Manifest', ocn_display: ''}
format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj)
@seg[:headings] << format_seg.title_heading1
@@ -131,10 +122,9 @@ WOK
@@loop_count=@@seg_total=@@tracker=0
@@is4=@@is3=@@is2=@@is1=0
@@heading1=@@heading2=@@heading3=@@heading4=0
- @@seg[:nav],@@seg[:title],@@seg[:headings],@@seg[:main],@@seg[:idx],@@seg[:tail],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(10){[]}
+ @@seg[:headings],@@seg[:main],@@seg[:idx],@@seg[:tail],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(7){[]}
@@seg[:heading_endnotes]=''
@@tablehead,@@number_of_cols=0,0
- @@segtocband=nil
@@fns_previous=''
attr_reader :seg_name_xhtml,:seg_name_xhtml_tracker
def initialize(md='',data='')
@@ -167,8 +157,8 @@ WOK
@@seg[:heading_idx]=''
end
data.each do |dob|
- if (dob.is=='heading' \
- || dob.is=='heading_insert') \
+ if (dob.is==:heading \
+ || dob.is==:heading_insert) \
and dob.ln==4
@@seg_name << dob.name
seg_name=dob.name
@@ -193,8 +183,8 @@ WOK
# # end
# #end
#end
- if (dob.is=='heading' \
- || dob.is=='heading_insert') \
+ if (dob.is==:heading \
+ || dob.is==:heading_insert) \
and dob.ln==4
if dob.ocn==0
@@heading4=dob.obj
@@ -202,27 +192,27 @@ WOK
end
@@is4=newfile=1
end
- if (dob.is=='heading' \
- || dob.is=='heading_insert') \
+ if (dob.is==:heading \
+ || dob.is==:heading_insert) \
and dob.ln==3
@@heading3=dob.obj
@@is4,@@is3=0,1
end
- if (dob.is=='heading' \
- || dob.is=='heading_insert') \
+ if (dob.is==:heading \
+ || dob.is==:heading_insert) \
and dob.ln==2
@@heading2=dob.obj
@@is4,@@is3,@@is2=0,0,1
end
- if (dob.is=='heading' \
- || dob.is=='heading_insert') \
+ if (dob.is==:heading \
+ || dob.is==:heading_insert) \
and dob.ln==1
@@heading1=dob.obj
@@is4,@@is3,@@is2,@@is1=0,0,0,1
end
if (@@is1 && !@@is2 && !@@is3 && !@@is4)
- if not (dob.is=='heading' \
- || dob.is=='heading_insert') \
+ if not (dob.is==:heading \
+ || dob.is==:heading_insert) \
and dob.ln==1
head1=$_ #; check
end
@@ -232,17 +222,17 @@ WOK
if newfile==1 \
or dob.obj =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/
newfile=0
- if (dob.is=='heading' \
- || dob.is=='heading_insert') \
+ if (dob.is==:heading \
+ || dob.is==:heading_insert) \
and dob.ln==4
if tracking != 0
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' \
+ if dob.is==:heading \
or @@seg_name_xhtml[tracking-1] !~/endnotes|book_index|metadata/
SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,@minitoc).output
- elsif dob.is=='heading_insert'
+ elsif dob.is==:heading_insert
if @@seg_name_xhtml[tracking-1]=='endnotes'
SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'endnotes').output
elsif @@seg_name_xhtml[tracking-1]=='book_index'
@@ -272,8 +262,8 @@ WOK
end
tracking=tracking+1
end
- if (dob.is=='heading' \
- || dob.is=='heading_insert') \
+ if (dob.is==:heading \
+ || dob.is==:heading_insert) \
and dob.ln==4 \
and dob.name
@@get_hash_to=dob.name
@@ -296,31 +286,16 @@ WOK
data
end
def heading_art(dob)
- format_head_seg=SiSU_EPUB_Format::HeadSeg.new(@md)
- if dob.is=='heading' \
- and dob.ln =~/^[1-6]/
- @@seg[:dot_nav]= (@@tracker < @@seg_total-1) \
- ? format_head_seg.dot_control_pre_next
- : format_head_seg.dot_control_pre
- end
- @@seg[:title]=format_head_seg.head
+ @@seg[:title]=SiSU_EPUB_Format::HeadSeg.new(@md).head
end
def head(dob)
clean=/<!.*?!>|<:.*?>$/
- format_head_seg=SiSU_EPUB_Format::HeadSeg.new(@md)
- if @@tracker < @@seg_total-1
- @@segtocband=(@@tracker==0) \
- ? format_head_seg.toc_next2
- : format_head_seg.toc_pre_next2
- else @@segtocband=format_head_seg.toc_pre2 #if format_head_seg.toc_pre2
- end
@p_num ||= ''
if @@is1==1
if defined? @md.creator.author \
and @md.creator.author
@author=%{<b>#{@md.creator.author}</b>\n}
end
- @@seg[:nav] << format_head_seg.navigation_band(@@segtocband)
ocn=if @@heading1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix
else ''
end
@@ -366,23 +341,25 @@ WOK
end
def markup(dob)
@debug=[]
- format_head_seg=SiSU_EPUB_Format::HeadSeg.new(@md)
- if dob.is =~/(?:heading|para)/ #extend as necessary FIX
+ if dob.is ==:heading \
+ || dob.is ==:heading_insert \
+ || dob.is ==:para
+ #extend as necessary FIX
@p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,dob.ocn)
end
sto=SiSU_EPUB_Format::FormatTextObject.new(@md,dob)
- dob_xhtml=if dob.is=='heading' \
- or dob.is=='heading_insert' \
- or dob.is=='para'
- dob_xhtml=if dob.is=='heading' \
- or dob.is=='heading_insert'
+ dob_xhtml=if dob.is==:heading \
+ || dob.is==:heading_insert \
+ || dob.is==:para
+ dob_xhtml=if dob.is==:heading \
+ or dob.is==:heading_insert
if dob.ln==4
sto.seg_heading4 # work on see SplitTextObject
elsif dob.ln==5
sto.seg_heading5
elsif dob.ln==6; sto.seg_heading6
end
- elsif dob.is=='para'
+ elsif dob.is==:para
if dob.indent \
and dob.hang \
and dob.indent =~/[0-9]/ \
@@ -400,33 +377,37 @@ WOK
else sto.para
end
end
- elsif dob.is =~/^(?:block|group|alt)$/
+ elsif dob.is ==:block \
+ || dob.is ==:group \
+ || dob.is ==:alt
sto.para #fix this should be block type specific #FIX
- elsif dob.is=='verse'
+ elsif dob.is==:verse
sto.verse
- elsif dob.is=='code'
+ elsif dob.is==:code
sto.code
- elsif dob.is=='table'
+ elsif dob.is==:table
sto.table
- elsif dob.is=='break'
+ elsif dob.is==:break
sto.break
end
if @md.flag_separate_endnotes # may need to revisit, check
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?)
+ if (dob.is ==:heading \
+ || dob.is==:heading_insert \
+ || dob.is==:para) \
+ && (not dob.ocn or dob.ocn.to_s.empty?)
format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,dob)
end
- if (dob.is=='heading' \
- || dob.is=='heading_insert' \
- || dob.is=='para') \
+ if (dob.is==:heading \
+ || dob.is==:heading_insert \
+ || dob.is==:para) \
and dob.note_ #dob.obj =~/<a href="#note_ref\d+">&nbsp;<sup id=/ #endnote- note-
format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,dob)
dob.obj=format_seg.no_paranum
end
- if (dob.is=='heading' \
- || dob.is=='heading_insert') \
+ if (dob.is==:heading \
+ || dob.is==:heading_insert) \
and dob.ln==4
@@seg[:main] << %{\n<div class="content">\n}
@@seg[:main] << dob_xhtml
@@ -451,8 +432,7 @@ WOK
@@seg[:close] << format_head_seg.xhtml_close
end
def reinitialise
- @@seg[:title],@@seg[:dot_nav],@@seg[:nav],@@seg[:headings],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(8){[]}
- @@segtocband=nil
+ @@seg[:headings],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(4){[]}
end
def cleanup
reinitialise
@@ -465,8 +445,8 @@ WOK
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') \
+ if (dob.is==:heading \
+ || dob.is==:heading_insert) \
and dob.ln.to_s =~/^[1234]/ \
and not @@fn.to_s.empty?
@@seg_endnotes[@@fn]=[]
@@ -474,8 +454,8 @@ WOK
@@seg_endnotes_array=[] if dob.ln==4
@@fns_previous=@md.fns if dob.ln==4 and dob.name =~/^meta/
end
- if (dob.is=='heading' \
- || dob.is=='heading_insert') \
+ if (dob.is==:heading \
+ || dob.is==:heading_insert) \
and dob.ln==4 #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs
@@seg_subtoc[@@fn]=@@seg_subtoc_array
@@seg_subtoc_array=[]
@@ -489,7 +469,7 @@ WOK
end
end
end
- if dob.is=='heading' \
+ if dob.is==:heading \
and dob.ln.to_s =~/^[56]/
case dob.ln
when 5
@@ -504,7 +484,7 @@ WOK
if @md.flag_auto_endnotes
ast,pls='&#042;','&#043;'
if dob.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(?:\d|#{ast}|#{pls})+ / \
- and dob.is !~/^code/ # endnote-
+ and dob.is !=:code # endnote-
endnote_array=[]
if dob.obj=~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m
endnote_array << dob.obj.scan(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m)