Skip to content

Commit

Permalink
delay data uri conversion to the very end: closes metanorma/metanorma…
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed May 4, 2020
1 parent bca8616 commit cba1510
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/asciidoctor/standoc/cleanup.rb
Expand Up @@ -64,6 +64,7 @@ def cleanup(xmldoc)
boilerplate_cleanup(xmldoc)
smartquotes_cleanup(xmldoc)
para_cleanup(xmldoc)
img_cleanup(xmldoc)
xmldoc
end

Expand Down Expand Up @@ -158,6 +159,13 @@ def bpart_cleanup(xmldoc)
x.replace(x.children)
end
end

def img_cleanup(xmldoc)
return xmldoc unless @datauriimage
xmldoc.xpath("//image").each do |i|
i["src"] = datauri(i["src"])
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/asciidoctor/standoc/inline.rb
Expand Up @@ -197,7 +197,7 @@ def image_attributes(node)
types = /^data:/.match(uri) ? datauri2mime(uri) : MIME::Types.type_for(uri)
type = types.first.to_s
uri = uri.sub(%r{^data:image/\*;}, "data:#{type};")
attr_code(src: @datauriimage ? datauri(uri) : uri,
attr_code(src: uri, #@datauriimage ? datauri(uri) : uri,
id: Utils::anchor_or_uuid,
mimetype: type,
height: node.attr("height") || "auto",
Expand Down

0 comments on commit cba1510

Please sign in to comment.