emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/htmlize c34b364 053/134: Create an image with a data: URI


From: ELPA Syncer
Subject: [nongnu] elpa/htmlize c34b364 053/134: Create an image with a data: URI for image data descriptors.
Date: Sat, 7 Aug 2021 09:17:05 -0400 (EDT)

branch: elpa/htmlize
commit c34b3648e72103a259838693cda12bf6e77dd1f6
Author: Hrvoje Niksic <hniksic@gmail.com>
Commit: Hrvoje Niksic <hniksic@gmail.com>

    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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]