From fd1c84b6a8ede458f3daf6da38d0564298912f40 Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Fri, 7 Jan 2022 21:37:48 +0900 Subject: [PATCH 1/2] correct epub:type. Closes: #1776 --- lib/review/epubmaker/epubcommon.rb | 13 +++++++++---- lib/review/epubmaker/epubv3.rb | 7 +++++-- test/test_epub3maker.rb | 10 +++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/review/epubmaker/epubcommon.rb b/lib/review/epubmaker/epubcommon.rb index f0522b196..080b1f57e 100644 --- a/lib/review/epubmaker/epubcommon.rb +++ b/lib/review/epubmaker/epubcommon.rb @@ -1,6 +1,6 @@ # = epubcommon.rb -- super class for EPUBv2 and EPUBv3 # -# Copyright (c) 2010-2021 Kenshi Muto and Masayoshi Takahashi +# Copyright (c) 2010-2022 Kenshi Muto and Masayoshi Takahashi # # This program is free software. # You can distribute or modify this program under the terms of @@ -103,7 +103,7 @@ def coverimage # If Producer#config["coverimage"] is defined, it will be used for # the cover image. def cover - @body_ext = config['epubversion'] >= 3 ? %Q( epub:type="cover") : '' + @body_ext = config['epubversion'] >= 3 ? %Q( epub:type="cover") : nil if config['coverimage'] @coverimage_src = coverimage @@ -119,7 +119,9 @@ def cover else './html/layout-xhtml1.html.erb' end - ReVIEW::Template.generate(path: template_path, binding: binding) + ret = ReVIEW::Template.generate(path: template_path, binding: binding) + @body_ext = nil + ret end # Return title (copying) content. @@ -212,6 +214,7 @@ def date_to_s(date) def mytoc @title = h(ReVIEW::I18n.t('toctitle')) + @body_ext = config['epubversion'] >= 3 ? %Q( epub:type="toc") : nil @body = %Q(

#{h(ReVIEW::I18n.t('toctitle'))}

\n) if config['epubmaker']['flattoc'].nil? @body << hierarchy_ncx('ul') @@ -226,7 +229,9 @@ def mytoc else './html/layout-xhtml1.html.erb' end - ReVIEW::Template.generate(path: template_path, binding: binding) + ret = ReVIEW::Template.generate(path: template_path, binding: binding) + @body_ext = nil + ret end def hierarchy_ncx(type) diff --git a/lib/review/epubmaker/epubv3.rb b/lib/review/epubmaker/epubv3.rb index ae650b513..646fe5c09 100644 --- a/lib/review/epubmaker/epubv3.rb +++ b/lib/review/epubmaker/epubv3.rb @@ -1,6 +1,6 @@ # = epubv3.rb -- EPUB version 3 producer. # -# Copyright (c) 2010-2017 Kenshi Muto +# Copyright (c) 2010-2022 Kenshi Muto # # This program is free software. # You can distribute or modify this program under the terms of @@ -195,6 +195,7 @@ def opf_tocx end def ncx(indentarray) + @body_ext = %Q( epub:type="toc") ncx_main = if config['epubmaker']['flattoc'].nil? hierarchy_ncx('ol') else @@ -210,7 +211,9 @@ def ncx(indentarray) @title = h(ReVIEW::I18n.t('toctitle')) @language = config['language'] @stylesheets = config['stylesheet'] - ReVIEW::Template.generate(path: './html/layout-html5.html.erb', binding: binding) + ret = ReVIEW::Template.generate(path: './html/layout-html5.html.erb', binding: binding) + @body_ext = nil + ret end # Produce EPUB file +epubfile+. diff --git a/test/test_epub3maker.rb b/test/test_epub3maker.rb index 968737221..d13f6b47b 100644 --- a/test/test_epub3maker.rb +++ b/test/test_epub3maker.rb @@ -170,7 +170,7 @@ def test_stage1_ncx Table of Contents - +