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

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

[elpa] externals/org 4514a32: org: More carefully interpret image width


From: ELPA Syncer
Subject: [elpa] externals/org 4514a32: org: More carefully interpret image width attrs
Date: Mon, 22 Nov 2021 12:57:28 -0500 (EST)

branch: externals/org
commit 4514a324c86a408951a0553a390a01981d61c367
Author: TEC <tec@tecosaur.com>
Commit: TEC <tec@tecosaur.com>

    org: More carefully interpret image width attrs
    
    * lisp/org.el (org-display-inline-image--width): Before attempting to
    interpret a :width attribute numerically, check that it indeed starts
    with a digit and use the default value given by `org-image-actual-width'
    if not.  However, if a value of "t" is given, treat this as if
    `org-image-actual-width' were "t" and just use the image's pixel width.
    
    This change fixes a strange behaviour where a non-numeric width would
    previously display the image with zero width.
---
 lisp/org.el | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index df3d139..52e9088 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16860,15 +16860,18 @@ buffer boundaries with possible narrowing."
             (when (and par (org-with-point-at
                                (org-element-property :begin par)
                              (re-search-forward attr-re par-end t)))
-              (match-string 1)))
-           (attr-width-val
+              (match-string 1))))
             (cond
-             ((null attr-width) nil)
+             ;; Treat :width t as if `org-image-actual-width' were t.
+             ((string= attr-width "t") nil)
+             ;; Fallback to `org-image-actual-width' if no interprable width 
is given.
+             ((or (null attr-width)
+                  (string-match-p "\\`[^0-9]"))
+              (car org-image-actual-width))
+             ;; Convert numeric widths to numbers, converting percentages.
              ((string-match-p "\\`[0-9.]+%" attr-width)
               (/ (string-to-number attr-width) 100.0))
              (t (string-to-number attr-width))))
-           ;; Fallback to `org-image-actual-width' if no explicit width is 
given.
-           (width (or attr-width-val (car org-image-actual-width))))
       (if (and (floatp width) (<= 0.0 width 2.0))
           ;; A float in [0,2] should be interpereted as this portion of
           ;; the text width in the window.  This works well with cases like



reply via email to

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