lib/isodoc/function/utils.rb in isodoc-1.0.9 vs lib/isodoc/function/utils.rb in isodoc-1.0.10
- old
+ new
@@ -1,8 +1,7 @@
module IsoDoc::Function
module Utils
-
def date_range(date)
self.class.date_range(date)
end
def ns(xpath)
@@ -38,12 +37,12 @@
attributes.map do |k, v|
[k, (v.is_a? String) ? HTMLEntities.new.decode(v) : v]
end.to_h
end
- DOCTYPE_HDR = '<!DOCTYPE html SYSTEM
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.freeze
+ DOCTYPE_HDR = '<!DOCTYPE html SYSTEM '\
+ '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.freeze
def to_xhtml(xml)
xml.gsub!(/<\?xml[^>]*>/, "")
/<!DOCTYPE /.match xml or xml = DOCTYPE_HDR + xml
xml = xml.split(/(\&[^ \r\n\t#;]+;)/).map do |t|
@@ -113,10 +112,11 @@
h1 = to_xhtml_fragment(h.dup)
h1.traverse do |x|
x.replace(" ") if x.name == "span" && /mso-tab-count/.match(x["style"])
x.remove if x.name == "span" && x["class"] == "MsoCommentReference"
x.remove if x.name == "a" && x["epub:type"] == "footnote"
+ x.remove if x.name == "span" && /mso-bookmark/.match(x["style"])
x.replace(x.children) if x.name == "a"
end
from_xhtml(h1)
end
@@ -162,9 +162,19 @@
Tempfile.open(["image", ".#{imgtype}"]) do |f|
f.binmode
f.write(Base64.strict_decode64(imgdata))
@tempfile_cache << f #persist to the end
f.path
+ end
end
+
+ def image_localfile(i)
+ if /^data:image/.match i["src"]
+ save_dataimage(i["src"], false)
+ elsif %r{^([A-Z]:)?/}.match i["src"]
+ i["src"]
+ else
+ File.join(@localdir, i["src"])
+ end
end
end
end