forked from mirrors/org-mode
ox-html: Fix spurious "figure" divs on empty paragraphs
* lisp/ox-html.el (org-html-standalone-image-p): Ensure paragraph contains at least a link before return a non-nil value. Clarify docstring. Thanks to Fabrice Popineau for reporting it. http://permalink.gmane.org/gmane.emacs.orgmode/86314
This commit is contained in:
parent
e242bc5180
commit
ab1ce2a757
|
@ -2596,18 +2596,17 @@ if its description is a single link targeting an image file."
|
||||||
|
|
||||||
(defvar org-html-standalone-image-predicate)
|
(defvar org-html-standalone-image-predicate)
|
||||||
(defun org-html-standalone-image-p (element info)
|
(defun org-html-standalone-image-p (element info)
|
||||||
"Test if ELEMENT is a standalone image.
|
"Non-nil if ELEMENT is a standalone image.
|
||||||
|
|
||||||
INFO is a plist holding contextual information.
|
INFO is a plist holding contextual information.
|
||||||
|
|
||||||
Return non-nil, if ELEMENT is of type paragraph and its sole
|
An element or object is a standalone image when
|
||||||
content, save for white spaces, is a link that qualifies as an
|
|
||||||
inline image.
|
|
||||||
|
|
||||||
Return non-nil, if ELEMENT is of type link and its containing
|
- its type is `paragraph' and its sole content, save for white
|
||||||
paragraph has no other content save white spaces.
|
spaces, is a link that qualifies as an inline image;
|
||||||
|
|
||||||
Return nil, otherwise.
|
- its type is `link' and its containing paragraph has no other
|
||||||
|
content save white spaces.
|
||||||
|
|
||||||
Bind `org-html-standalone-image-predicate' to constrain paragraph
|
Bind `org-html-standalone-image-predicate' to constrain paragraph
|
||||||
further. For example, to check for only captioned standalone
|
further. For example, to check for only captioned standalone
|
||||||
|
@ -2618,19 +2617,21 @@ images, set it to:
|
||||||
(paragraph element)
|
(paragraph element)
|
||||||
(link (org-export-get-parent element)))))
|
(link (org-export-get-parent element)))))
|
||||||
(and (eq (org-element-type paragraph) 'paragraph)
|
(and (eq (org-element-type paragraph) 'paragraph)
|
||||||
(or (not (and (boundp 'org-html-standalone-image-predicate)
|
(or (not (fboundp 'org-html-standalone-image-predicate))
|
||||||
(functionp org-html-standalone-image-predicate)))
|
|
||||||
(funcall org-html-standalone-image-predicate paragraph))
|
(funcall org-html-standalone-image-predicate paragraph))
|
||||||
(not (let ((link-count 0))
|
(catch 'exit
|
||||||
(org-element-map (org-element-contents paragraph)
|
(let ((link-count 0))
|
||||||
(cons 'plain-text org-element-all-objects)
|
(org-element-map (org-element-contents paragraph)
|
||||||
(lambda (obj) (case (org-element-type obj)
|
(cons 'plain-text org-element-all-objects)
|
||||||
(plain-text (org-string-nw-p obj))
|
#'(lambda (obj)
|
||||||
(link
|
(when (case (org-element-type obj)
|
||||||
(or (> (incf link-count) 1)
|
(plain-text (org-string-nw-p obj))
|
||||||
(not (org-html-inline-image-p obj info))))
|
(link (or (> (incf link-count) 1)
|
||||||
(otherwise t)))
|
(not (org-html-inline-image-p obj info))))
|
||||||
info 'first-match 'link))))))
|
(otherwise t))
|
||||||
|
(throw 'exit nil)))
|
||||||
|
info nil 'link)
|
||||||
|
(= link-count 1))))))
|
||||||
|
|
||||||
(defun org-html-link (link desc info)
|
(defun org-html-link (link desc info)
|
||||||
"Transcode a LINK object from Org to HTML.
|
"Transcode a LINK object from Org to HTML.
|
||||||
|
|
Loading…
Reference in a new issue