branch: elpa/htmlize
commit c34b3648e72103a259838693cda12bf6e77dd1f6
Author: Hrvoje Niksic <[email protected]>
Commit: Hrvoje Niksic <[email protected]>
Create an image with a data: URI for image data descriptors.
---
htmlize.el | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/htmlize.el b/htmlize.el
index 7591ba7..10511ba 100644
--- a/htmlize.el
+++ b/htmlize.el
@@ -438,7 +438,11 @@ next-single-char-property-change")))
(cond ((plist-get imgprops :file)
(format "<img src=\"%s\" />"
(htmlize-protect-string (file-relative-name
- (plist-get imgprops :file)))))))
+ (plist-get imgprops :file)))))
+ ((plist-get imgprops :data)
+ (format "<img src=\"data:image/%s;base64,%s\" />"
+ (or (plist-get imgprops :type) "")
+ (base64-encode-string (plist-get imgprops :data))))))
(defconst htmlize-ellipsis "...")
(put-text-property 0 (length htmlize-ellipsis) 'htmlize-ellipsis t
htmlize-ellipsis)