Skip to content

Commit

Permalink
epub2html: compare with File.basename
Browse files Browse the repository at this point in the history
It assumes that all HTML files are in the same directory and that there are no duplicate filenames.
  • Loading branch information
takahashim committed Jan 10, 2022
1 parent 64e7e00 commit 8f3fd82
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/review/epub2html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def parse_epub(epubname)
opf = entry.get_input_stream.read
@opfxml = REXML::Document.new(opf)
elsif /.+\.x?html\Z/.match?(entry.name)
htmls[entry.name.sub('OEBPS/', '')] = entry.get_input_stream.read.force_encoding('utf-8')
htmls[File.basename(entry.name)] = entry.get_input_stream.read.force_encoding('utf-8')
end
end
end
Expand Down Expand Up @@ -145,7 +145,8 @@ def modify_html(fname, html)
def join_html(reffile, htmls)
head = tail = nil
body = []
make_list.each do |fname|
make_list.each do |href_value|
fname = File.basename(href_value)
if head.nil? && (reffile.nil? || reffile == fname)
head, tail = take_headtail(htmls[fname])
end
Expand Down

0 comments on commit 8f3fd82

Please sign in to comment.