aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5/xhtml_epub2.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-01-06 23:05:26 -0500
committerRalph Amissah <ralph@amissah.com>2014-01-06 23:05:26 -0500
commit4075d476731a7a1c29e399d60f6baa210f3d1cb4 (patch)
treeb0fab3d856f64f0562b7b7da317cf79c3b3e05f1 /lib/sisu/v5/xhtml_epub2.rb
parentdebian/changelog (4.2.16-1) (diff)
parentv5: heading recalibration, code (downstream) changes (diff)
Merge tag 'sisu_4.2.17' into debian/sid
SiSU 4.2.17
Diffstat (limited to 'lib/sisu/v5/xhtml_epub2.rb')
-rw-r--r--lib/sisu/v5/xhtml_epub2.rb85
1 files changed, 67 insertions, 18 deletions
diff --git a/lib/sisu/v5/xhtml_epub2.rb b/lib/sisu/v5/xhtml_epub2.rb
index c54d77ff..33e3a529 100644
--- a/lib/sisu/v5/xhtml_epub2.rb
+++ b/lib/sisu/v5/xhtml_epub2.rb
@@ -8,7 +8,8 @@
* Author: Ralph Amissah
* Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
- 2007, 2008, 2009, 2010, 2011, 2012, 2013 Ralph Amissah, All Rights Reserved.
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah,
+ All Rights Reserved.
* License: GPL 3 or later:
@@ -208,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
@@ -230,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
@@ -239,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
@@ -250,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
@@ -273,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
@@ -281,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]
@@ -363,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>"
@@ -380,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
@@ -421,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)
@@ -440,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)
@@ -459,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]}">
@@ -484,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 !~/#/
@@ -504,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 !~/#/