Skip to content

Commit 0a7055d

Browse files
xzz53nnicandro
authored andcommitted
Add optional image width limiting for REPL
1 parent 42a9765 commit 0a7055d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

jupyter-mime.el

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@
4848
(declare-function markdown-link-at-pos "ext:markdown-mode" (pos))
4949
(declare-function markdown-follow-link-at-point "ext:markdown-mode")
5050

51+
;;; User variables
52+
53+
(defcustom jupyter-image-max-width 0
54+
"Maximum width of images in REPL.
55+
Wider images are resized. Special value 0 means no limit."
56+
:type 'integer
57+
:group 'jupyter-repl)
58+
59+
;;; Implementation
60+
5161
(defvar-local jupyter-display-ids nil
5262
"A hash table of display IDs.
5363
Display IDs are implemented by setting the text property,
@@ -480,6 +490,8 @@ width and height of the image."
480490
metadata
481491
(let ((img (create-image
482492
data type 'data :width width :height height
493+
:max-width (when (> jupyter-image-max-width 0)
494+
jupyter-image-max-width)
483495
:mask (when needs_background
484496
'(heuristic t)))))
485497
(insert-image img))))

0 commit comments

Comments
 (0)