Permalink
Browse files

Fixed e-Pub warnings informed by epubchecker.

There is only one warning that I couldn't fix though.
The cover image complains about not recognizing the
'image/png' media type. Will try to get into this later.
  • Loading branch information...
1 parent 18ba16b commit fe63e8e8c878fce4f7d4390e8898a634b6928523 @fnando committed Aug 15, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/kitabu/parser/epub.rb
@@ -28,7 +28,7 @@ def parse
epub.date config[:published_at]
epub.uid config[:uid]
epub.identifier config[:identifier][:id], :scheme => config[:identifier][:type]
- epub.cover_page cover_image
+ epub.cover_page cover_image if cover_image && File.exist?(cover_image)
write_sections!
write_toc!
@@ -80,14 +80,17 @@ def write_sections!
section.html.css("[src]").each do |element|
src = File.basename(element["src"]).gsub(/\.svg$/, ".png")
element.set_attribute("src", src)
+ element.set_attribute("alt", "")
+ element.node_name = "img"
end
FileUtils.mkdir_p(tmp_dir)
# Save file to disk.
#
File.open(section.filepath, "w") do |file|
- file << render_chapter(section.html.css("body").inner_html)
+ body = section.html.css("body").to_xhtml.gsub(%r[<body>(.*?)</body>]m, "\\1")
+ file << render_chapter(body)
end
end
end
@@ -101,7 +104,6 @@ def assets
@assets ||= begin
assets = Dir[root_dir.join("templates/epub/*.css")]
assets += Dir[root_dir.join("images/**/*.{jpg,png,gif}")]
- assets << cover_image if cover_image
assets
end
end

0 comments on commit fe63e8e

Please sign in to comment.