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.rb94
1 files changed, 50 insertions, 44 deletions
diff --git a/lib/sisu/v3dv/epub_segments.rb b/lib/sisu/v3dv/epub_segments.rb
index a9747cd5..55c6c1f9 100644
--- a/lib/sisu/v3dv/epub_segments.rb
+++ b/lib/sisu/v3dv/epub_segments.rb
@@ -157,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
@@ -183,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
@@ -192,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
@@ -222,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'
@@ -262,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
@@ -341,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]/ \
@@ -375,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
@@ -439,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]=[]
@@ -448,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=[]
@@ -463,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
@@ -478,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)