summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIhor Radchenko <yantar92@posteo.net>2024-06-11 12:42:28 +0200
committerIhor Radchenko <yantar92@posteo.net>2024-06-11 12:44:57 +0200
commit3e4c89e55649f95cffbf70fcf64dcbc69760f96f (patch)
tree1bbc3b95e2edfb51da07b47ba8712da7012df381
parent9419dad48ae340c80bf76953c0b8b1eacffea42c (diff)
org-image--align: Fix image alignment when image is not inside paragraph
* lisp/org.el (org-image--align): Improve docstring. Do not try to align when image is not inside a paragraph. Reported-by: Lin Sun <sunlin7.mail@gmail.com> Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71484
-rw-r--r--lisp/org.el12
1 files changed, 7 insertions, 5 deletions
diff --git a/lisp/org.el b/lisp/org.el
index ff5b63212..1698399c4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16981,10 +16981,11 @@ buffer boundaries with possible narrowing."
(t nil))))
(defun org-image--align (link)
- "Determine the alignment of the image link.
+ "Determine the alignment of the image LINK.
+LINK is a link object.
In decreasing order of priority, this is controlled:
-- Per image by the value of `:center' or ``:align' in the
+- Per image by the value of `:center' or `:align' in the
affiliated keyword `#+attr_org'.
- By the `#+attr_html' or `#+attr_latex` keywords with valid
`:center' or `:align' values.
@@ -16998,15 +16999,16 @@ will cause it to be right-aligned. A value of \"left\" or nil
implies no special alignment."
(let ((par (org-element-lineage link 'paragraph)))
;; Only align when image is not surrounded by paragraph text:
- (when (and (= (org-element-begin link)
+ (when (and par ; when image is not in paragraph, but in table/headline/etc, do not align
+ (= (org-element-begin link)
(save-excursion
(goto-char (org-element-contents-begin par))
(skip-chars-forward "\t ")
(point))) ;account for leading space
;before link
(<= (- (org-element-contents-end par)
- (org-element-end link))
- 1)) ;account for trailing newline
+ (org-element-end link))
+ 1)) ;account for trailing newline
;at end of paragraph
(save-match-data
;; Look for a valid ":center t" or ":align left|center|right"