diff options
authorBastien Guerry <>2013-03-19 18:35:44 (GMT)
committer Bastien Guerry <>2013-03-19 18:39:35 (GMT)
commiteff59a15d76647ce8282626b9eb463dc3706d56e (patch)
parent9cd0810f90690a7632d11548ec2e2d9bd8be19de (diff)
ox-html.el: Use the correct syntax for image and link attributes
* ox-html.el (org-html-link--inline-image): Use the correct syntax for image attributes. Allow :width :height and :alt as predefined attributes for inline images. (org-html-link, org-html-table): Use the standard syntax--- e.g. "#+attr_html: :options ..."--- to get attributes.
1 files changed, 21 insertions, 13 deletions
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 046de9b..520f3ca 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2411,7 +2411,11 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(defun org-html-link--inline-image (link desc info)
"Return HTML code for an inline image.
LINK is the link pointing to the inline image. INFO is a plist
-used as a communication channel."
+used as a communication channel.
+Inline images can have these attributes:
+#+ATTR_HTML: :width 100px :height 100px :alt \"Alt description\"."
(let* ((type (org-element-property :type link))
(raw-path (org-element-property :path link))
(path (cond ((member type '("http" "https"))
@@ -2422,10 +2426,19 @@ used as a communication channel."
(parent (org-export-get-parent-element link))
(caption (org-export-data (org-export-get-caption parent) info))
(label (org-element-property :name parent))
- (attr (mapconcat #'identity (org-element-property :attr_html parent) " ")))
+ (alt (org-export-read-attribute :attr_html parent :alt))
+ (width (org-export-read-attribute :attr_html parent :width))
+ (height (org-export-read-attribute :attr_html parent :height))
+ (options (org-export-read-attribute :attr_html parent :options)))
;; Return proper string, depending on DISPOSITION.
- path caption label attr (org-html-standalone-image-p link info))))
+ path caption label
+ (mapconcat 'identity
+ (delq nil (list (if width (format "width=\"%s\"" width))
+ (if alt (format "alt=\"%s\"" alt))
+ (if height (format "height=\"%s\"" height))
+ options)) " ")
+ (org-html-standalone-image-p link info))))
(defvar org-html-standalone-image-predicate)
(defun org-html-standalone-image-p (element info &optional predicate)
@@ -2534,13 +2547,9 @@ INFO is a plist holding contextual information. See
(if (not (eq (org-element-map parent 'link 'identity info t)
- (mapconcat
- 'identity
- (let ((att (org-element-property :attr_html parent)))
- (unless (and desc att
- (string-match (regexp-quote (car att)) desc))
- att))
- " "))))
+ (let ((att (org-export-read-attribute :attr_html parent :options)))
+ (unless (and desc att (string-match (regexp-quote att) desc))
+ att)))))
(unless (string= attributes "")
(setq attributes (concat " " attributes))))
@@ -3012,9 +3021,8 @@ contextual information."
(let* ((label (org-element-property :name table))
(caption (org-export-get-caption table))
- (attributes (mapconcat #'identity
- (org-element-property :attr_html table)
- " "))
+ (attributes
+ (org-export-read-attribute :attr_html table :options))
(if (and (boundp 'org-html-format-table-no-css)