aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5/xhtml_epub2.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-01-06 23:02:50 -0500
committerRalph Amissah <ralph@amissah.com>2014-01-06 23:03:02 -0500
commit5fb49b575a548313b827fd66fd7ecce514fe0e45 (patch)
treee7541789806c1bc086c05d06f0af2b9d54abb1c1 /lib/sisu/v5/xhtml_epub2.rb
parentv5: vim syntax, v5.2 match heading level D~ (diff)
v5: heading recalibration, code (downstream) changessisu_4.2.17
* here no doubt remains breakage (test, fix & test again)
Diffstat (limited to 'lib/sisu/v5/xhtml_epub2.rb')
-rw-r--r--lib/sisu/v5/xhtml_epub2.rb82
1 files changed, 65 insertions, 17 deletions
diff --git a/lib/sisu/v5/xhtml_epub2.rb b/lib/sisu/v5/xhtml_epub2.rb
index 27496f99..33e3a529 100644
--- a/lib/sisu/v5/xhtml_epub2.rb
+++ b/lib/sisu/v5/xhtml_epub2.rb
@@ -209,7 +209,7 @@ module SiSU_XHTML_EPUB2
@@toc={ seg: [], seg_mini: [], scr: [], ncx: [], opf: [] }
md_opf_a_content,md_opf_a_spine,md_opf_a_guide=[],[],[]
@nav_no=0
- @s_a_no,@s_b_no,@s_c_no,@lv5_no,@lv6_no=0,0,0,0,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
@@ -231,7 +231,7 @@ module SiSU_XHTML_EPUB2
md_opf_a_spine << @epub.metadata_opf.spine_sisu_toc
md_opf_a_guide << @epub.metadata_opf.guide_sisu_toc
end
- @ncxo=[nil,false,false,false,false,false,false]
+ @ncxo=[false,false,false,false,false,false,false]
@dob_toc2,@dob_toc3=nil,nil
@ncx_cls=[]
@level_a_first_occurrence=true
@@ -240,7 +240,7 @@ module SiSU_XHTML_EPUB2
|| dob.is==:heading_insert
dob_toc=dob.dup
toc=case dob_toc.ln
- when 1
+ when 0
@s_a_no +=1
lv_name='section_a' + @s_a_no.to_s
@nav_no+=1
@@ -251,20 +251,21 @@ module SiSU_XHTML_EPUB2
@@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]
- @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=true,false,false,false,false,false
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[0]
+ @ncxo[0],@ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=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
if @level_a_first_occurrence \
&& @make.build.toc?
- @nav_no+=1
@@toc[: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
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
+ 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
@@ -274,6 +275,24 @@ module SiSU_XHTML_EPUB2
@@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]
+ @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=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
+ 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
+ @@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]
@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=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
@@ -282,8 +301,8 @@ module SiSU_XHTML_EPUB2
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_c_no +=1
- lv_name='section_c' + @s_c_no.to_s
+ @s_d_no +=1
+ 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[6]
@@ -364,7 +383,8 @@ module SiSU_XHTML_EPUB2
@@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]
- @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=false,false,false,false,false,false
+ @@toc[: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>"
@@ -381,9 +401,32 @@ module SiSU_XHTML_EPUB2
@@toc
end
protected
+ def level_0
+ dob=@data
+ linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip
+ link=dob.ocn
+ title=linkname
+ toc={}
+ txt_obj={ txt: title }
+ format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj)
+ toc[:seg]=format_toc.lev1
+ title=if dob.ocn ==0 then linkname
+ else
+ @@toc[:scr] << '<br />'
+ link=(dob.ln) \
+ ? dob.ln
+ : ''
+ %{<b><a href="##{link}">#{linkname}</a></b>}
+ end
+ txt_obj={ txt: title }
+ format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj)
+ toc[:scr]=format_toc.lev1
+ toc
+ end
def level_1
dob=@data
- linkname,link=dob.obj.strip,dob.ocn
+ linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip
+ link=dob.ocn
title=if dob.obj !~/Document Information/
linkname
else
@@ -422,7 +465,8 @@ module SiSU_XHTML_EPUB2
end
def level_2
dob=@data
- linkname,ocn=dob.obj.strip,dob.ocn
+ linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip
+ ocn=dob.ocn
if ocn \
and ocn !~/#/
p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,ocn)
@@ -441,7 +485,8 @@ module SiSU_XHTML_EPUB2
end
def level_3
dob=@data
- linkname,ocn=dob.obj.strip,dob.ocn
+ linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip
+ ocn=dob.ocn
if ocn \
and ocn !~/#/
p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,ocn)
@@ -460,7 +505,8 @@ module SiSU_XHTML_EPUB2
end
def level_4
dob=@data
- linkname,ocn=dob.obj.strip,dob.ocn
+ linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip
+ ocn=dob.ocn
p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,ocn) if ocn
if dob.ln==4
seg_link=%{ <a href="#{dob.name}#{Sfx[:epub_xhtml]}">
@@ -485,7 +531,8 @@ module SiSU_XHTML_EPUB2
end
def level_5
dob=@data
- linkname,ocn=dob.obj.strip,dob.ocn
+ linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip
+ ocn=dob.ocn
toc={}
if ocn \
and ocn !~/#/
@@ -505,7 +552,8 @@ module SiSU_XHTML_EPUB2
end
def level_6
dob=@data
- linkname,ocn=dob.obj.strip,dob.ocn
+ linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip
+ ocn=dob.ocn
toc={}
if ocn \
and ocn !~/#/