Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPUB生成では eps ファイルを png ファイルに変換する #148

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bin/review-epubmaker
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def main

if File.exist?("images")
Dir.mkdir("#{@bookdir}/OEBPS/images")
image_files = ReVIEW::MakerHelper.copy_images_to_dir("images", "#{@bookdir}/OEBPS/images")
image_files = ReVIEW::MakerHelper.copy_images_to_dir("images", "#{@bookdir}/OEBPS/images",
:convert => {:eps => :png})
image_files.each do |image_file|
dirname = File.dirname(image_file)
fname = File.basename(image_file)
Expand Down
6 changes: 5 additions & 1 deletion lib/review/htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,14 @@ def result_metric(array)
" #{array.join(' ')}"
end



def image_image(id, caption, metric)
metrics = parse_metric("html", metric)
img_path = @chapter.image(id).path.sub(/\A\.\//, "")
img_path = img_path + ".png" if img_path =~ /\.eps\Z/
puts %Q[<div class="image">]
puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{escape_html(compile_inline(caption))}"#{metrics} />]
puts %Q[<img src="#{img_path}" alt="#{escape_html(compile_inline(caption))}"#{metrics} />]
image_header id, caption
puts %Q[</div>]
end
Expand Down
11 changes: 11 additions & 0 deletions test/test_htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,17 @@ def @chapter.image(id)
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n|, @builder.raw_result
end

def test_image_eps
def @chapter.image(id)
item = Book::ImageIndex::Item.new("sampleimg",1)
item.instance_eval{@pathes=["./images/chap1-sampleimg.eps"]}
item
end

@builder.image_image("sampleimg","sample photo",nil)
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.eps.png" alt="sample photo" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n|, @builder.raw_result
end

def test_image_with_metric
def @chapter.image(id)
item = Book::ImageIndex::Item.new("sampleimg",1)
Expand Down