lib/isodoc/function/utils.rb in isodoc-1.8.2.2 vs lib/isodoc/function/utils.rb in isodoc-1.8.3
- old
+ new
@@ -35,14 +35,13 @@
l.gsub(/\s*\n/, "")
end
end
def attr_code(attributes)
- attributes = attributes.compact.map
- attributes.map do |k, v|
- [k, v.is_a?(String) ? HTMLEntities.new.decode(v) : v]
- end.to_h
+ attributes.compact.transform_values do |v|
+ v.is_a?(String) ? HTMLEntities.new.decode(v) : v
+ end
end
DOCTYPE_HDR = "<!DOCTYPE html SYSTEM "\
'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
@@ -186,14 +185,21 @@
f.path
end
end
def image_localfile(img)
+ case img["src"]
+ when /^data:/
+ save_dataimage(img["src"], false)
+ when %r{^([A-Z]:)?/}
+ img["src"]
+=begin
if /^data:/.match? img["src"]
save_dataimage(img["src"], false)
elsif %r{^([A-Z]:)?/}.match? img["src"]
img["src"]
+=end
else
File.join(@localdir, img["src"])
end
end
@@ -209,10 +215,9 @@
def cleanup_entities(text)
c = HTMLEntities.new
text.split(/([<>])/).each_slice(4).map do |a|
a[0] = c.encode(c.decode(a[0]), :hexadecimal)
- a[2] = c.encode(c.decode(a[2]), :hexadecimal) if a.size >= 3
a
end.join
end
def external_path(path)