Skip to content

Commit

Permalink
Fixed e-Pub warnings informed by epubchecker.
Browse files Browse the repository at this point in the history
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
fnando committed Aug 15, 2012
1 parent 18ba16b commit fe63e8e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/kitabu/parser/epub.rb
Expand Up @@ -28,7 +28,7 @@ def parse
epub.date config[:published_at] epub.date config[:published_at]
epub.uid config[:uid] epub.uid config[:uid]
epub.identifier config[:identifier][:id], :scheme => config[:identifier][:type] 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_sections!
write_toc! write_toc!
Expand Down Expand Up @@ -80,14 +80,17 @@ def write_sections!
section.html.css("[src]").each do |element| section.html.css("[src]").each do |element|
src = File.basename(element["src"]).gsub(/\.svg$/, ".png") src = File.basename(element["src"]).gsub(/\.svg$/, ".png")
element.set_attribute("src", src) element.set_attribute("src", src)
element.set_attribute("alt", "")
element.node_name = "img"
end end


FileUtils.mkdir_p(tmp_dir) FileUtils.mkdir_p(tmp_dir)


# Save file to disk. # Save file to disk.
# #
File.open(section.filepath, "w") do |file| 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 end
end end
Expand All @@ -101,7 +104,6 @@ def assets
@assets ||= begin @assets ||= begin
assets = Dir[root_dir.join("templates/epub/*.css")] assets = Dir[root_dir.join("templates/epub/*.css")]
assets += Dir[root_dir.join("images/**/*.{jpg,png,gif}")] assets += Dir[root_dir.join("images/**/*.{jpg,png,gif}")]
assets << cover_image if cover_image
assets assets
end end
end end
Expand Down

0 comments on commit fe63e8e

Please sign in to comment.