lib/isodoc/function/to_word_html.rb in isodoc-0.10.1 vs lib/isodoc/function/to_word_html.rb in isodoc-0.10.2
- old
+ new
@@ -1,6 +1,7 @@
require "fileutils"
+require "pathname"
module IsoDoc::Function
module ToWordHtml
def set_termdomain(termdomain)
@@ -14,27 +15,28 @@
def note?
@note
end
def init_file(filename, debug)
- filename = filename.gsub(%r{\.[^/.]+$}, "")
+ filepath = Pathname.new(filename)
+ filename = filepath.sub_ext('').to_s
dir = "#{filename}_files"
unless debug
Dir.mkdir(dir) unless File.exists?(dir)
FileUtils.rm_rf "#{dir}/*"
end
@filename = filename
- @localdir = %r{/}.match(filename) ? filename.sub(%r{/[^/]+$}, "/") : "./"
+ @localdir = filepath.parent.to_s + '/'
[filename, dir]
end
# tmp image dir is same directory as @filename
def tmpimagedir
@filename + tmpimagedir_suffix
end
def rel_tmpimagedir
- @filename.sub(%r{^.*/([^/]+)$}, "\\1") + tmpimagedir_suffix
+ Pathname.new(@filename).basename.to_s + tmpimagedir_suffix
end
# isodoc.css overrides any CSS injected by Html2Doc, which
# is inserted before this CSS.
def define_head(html, filename, _dir)