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
This commit is contained in:
parent
9419dad48a
commit
3e4c89e556
12
lisp/org.el
12
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"
|
||||
|
|
Loading…
Reference in New Issue