forked from mirrors/org-mode
ox-latex: Do not use float for inline images inside links
* lisp/ox.el (org-export-insert-image-links): Fix call to `org-element-set-contents' - setting "nil" literally would put an actual nil element into contents. * lisp/ox-latex.el (org-latex--inline-image): Do not use float environment unless the inline image is a single image inside paragraph. The code is adapted with simplifications from `org-html-standalone-image-p'. * testing/lisp/test-ox-latex.el (test-ox-latex/inline-image): New test. Reported-by: Dr. Arne Babenhauserheide <arne_bab@web.de> Link: https://orgmode.org/list/878rest3qv.fsf@localhost
This commit is contained in:
parent
59238cfa82
commit
38c6eb2b72
|
@ -2741,16 +2741,33 @@ used as a communication channel."
|
||||||
;; Retrieve latex attributes from the element around.
|
;; Retrieve latex attributes from the element around.
|
||||||
(attr (org-export-read-attribute :attr_latex parent))
|
(attr (org-export-read-attribute :attr_latex parent))
|
||||||
(float (let ((float (plist-get attr :float)))
|
(float (let ((float (plist-get attr :float)))
|
||||||
(cond ((string= float "wrap") 'wrap)
|
(cond
|
||||||
((string= float "sideways") 'sideways)
|
((org-element-map (org-element-contents parent) t
|
||||||
((string= float "multicolumn") 'multicolumn)
|
(lambda (node)
|
||||||
((string= float "t") 'figure)
|
(cond
|
||||||
((and (plist-member attr :float) (not float)) 'nonfloat)
|
((and (org-element-type-p node 'plain-text)
|
||||||
(float float)
|
(not (org-string-nw-p node)))
|
||||||
((or (org-element-property :caption parent)
|
nil)
|
||||||
(org-string-nw-p (plist-get attr :caption)))
|
((eq link node)
|
||||||
'figure)
|
;; Objects inside link description are
|
||||||
(t 'nonfloat))))
|
;; allowed.
|
||||||
|
(throw :org-element-skip nil))
|
||||||
|
(t 'not-a-float)))
|
||||||
|
info 'first-match)
|
||||||
|
;; Not a single link inside paragraph (spaces
|
||||||
|
;; ignored). Cannot use float environment. It
|
||||||
|
;; would be inside paragraph.
|
||||||
|
nil)
|
||||||
|
((string= float "wrap") 'wrap)
|
||||||
|
((string= float "sideways") 'sideways)
|
||||||
|
((string= float "multicolumn") 'multicolumn)
|
||||||
|
((string= float "t") 'figure)
|
||||||
|
((and (plist-member attr :float) (not float)) 'nonfloat)
|
||||||
|
(float float)
|
||||||
|
((or (org-element-property :caption parent)
|
||||||
|
(org-string-nw-p (plist-get attr :caption)))
|
||||||
|
'figure)
|
||||||
|
(t 'nonfloat))))
|
||||||
(placement
|
(placement
|
||||||
(let ((place (plist-get attr :placement)))
|
(let ((place (plist-get attr :placement)))
|
||||||
(cond
|
(cond
|
||||||
|
|
|
@ -4360,7 +4360,7 @@ Return modified DATA."
|
||||||
(or rules org-export-default-inline-image-rule))
|
(or rules org-export-default-inline-image-rule))
|
||||||
;; Replace contents with image link.
|
;; Replace contents with image link.
|
||||||
(org-element-adopt
|
(org-element-adopt
|
||||||
(org-element-set-contents l nil)
|
(org-element-set-contents l)
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(save-excursion (insert contents))
|
(save-excursion (insert contents))
|
||||||
(org-element-link-parser))))))))
|
(org-element-link-parser))))))))
|
||||||
|
|
|
@ -93,5 +93,16 @@ Column & Column \\\\[0pt]
|
||||||
"\\hline\\multicolumn{2}{r}{Continued on next page} \\\\
|
"\\hline\\multicolumn{2}{r}{Continued on next page} \\\\
|
||||||
\\endfoot"))))
|
\\endfoot"))))
|
||||||
|
|
||||||
|
(ert-deftest test-ox-latex/inline-image ()
|
||||||
|
"Test inline images."
|
||||||
|
(org-test-with-exported-text
|
||||||
|
'latex
|
||||||
|
"#+caption: Schematic
|
||||||
|
[[https://orgmode.org/worg/images/orgmode/org-mode-unicorn.svg][file:/wallpaper.png]]"
|
||||||
|
(goto-char (point-min))
|
||||||
|
(should
|
||||||
|
(search-forward
|
||||||
|
"\\href{https://orgmode.org/worg/images/orgmode/org-mode-unicorn.svg}{\\includegraphics[width=.9\\linewidth]{/wallpaper.png}}"))))
|
||||||
|
|
||||||
(provide 'test-ox-latex)
|
(provide 'test-ox-latex)
|
||||||
;;; test-ox-latex.el ends here
|
;;; test-ox-latex.el ends here
|
||||||
|
|
Loading…
Reference in New Issue