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

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

[elpa] externals/comint-mime 1431605: Encoding workaround for images


From: ELPA Syncer
Subject: [elpa] externals/comint-mime 1431605: Encoding workaround for images
Date: Tue, 30 Nov 2021 10:57:12 -0500 (EST)

branch: externals/comint-mime
commit 1431605940724318c403a6048049c6a32cc16b0e
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>

    Encoding workaround for images
    
    Following the code snipped in
    https://ipython.readthedocs.io/en/stable/config/shell_mimerenderer.html
    
    Fixes #8
---
 comint-mime.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/comint-mime.py b/comint-mime.py
index 323ef67..2033a55 100644
--- a/comint-mime.py
+++ b/comint-mime.py
@@ -12,9 +12,15 @@ def __COMINT_MIME_setup(types):
     from functools import partial
     from json import dumps as to_json
 
+    def encoding_workaround(data):
+        if isinstance(data, str):
+            from base64 import decodebytes
+            return decodebytes(data.encode())
+        return data
+
     MIME_TYPES = {
-        "image/png": None,
-        "image/jpeg": None,
+        "image/png": encoding_workaround,
+        "image/jpeg": encoding_workaround,
         "text/latex": str.encode,
         "text/html": str.encode,
         "application/json": lambda d: to_json(d).encode(),



reply via email to

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