lib/isodoc/function/utils.rb in isodoc-1.8.3.3 vs lib/isodoc/function/utils.rb in isodoc-1.8.4
- old
+ new
@@ -140,13 +140,13 @@
from_xhtml(h1)
end
def header_strip_elem?(elem)
elem.name == "img" ||
- elem.name == "span" && elem["class"] == "MsoCommentReference" ||
- elem.name == "a" && elem["class"] == "FootnoteRef" ||
- elem.name == "span" && /mso-bookmark/.match(elem["style"])
+ (elem.name == "span" && elem["class"] == "MsoCommentReference") ||
+ (elem.name == "a" && elem["class"] == "FootnoteRef") ||
+ (elem.name == "span" && /mso-bookmark/.match(elem["style"]))
end
def liquid(doc)
# unescape HTML escapes in doc
doc = doc.split(%r<(\{%|%\})>).each_slice(4).map do |a|
@@ -190,16 +190,10 @@
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
@@ -211,15 +205,19 @@
def emf?(type)
%w(application/emf application/x-emf image/x-emf image/x-mgx-emf
application/x-msmetafile image/x-xbitmap).include? type
end
- def cleanup_entities(text)
+ def cleanup_entities(text, is_xml: true)
c = HTMLEntities.new
- text.split(/([<>])/).each_slice(4).map do |a|
- a[0] = c.encode(c.decode(a[0]), :hexadecimal)
- a
- end.join
+ if is_xml
+ text.split(/([<>])/).each_slice(4).map do |a|
+ a[0] = c.encode(c.decode(a[0]), :hexadecimal)
+ a
+ end.join
+ else
+ c.encode(c.decode(text), :hexadecimal)
+ end
end
def external_path(path)
win = !!((RUBY_PLATFORM =~ /(win|w)(32|64)$/) ||
(RUBY_PLATFORM =~ /mswin|mingw/))