diff options
author | Bastien Guerry <bzg@altern.org> | 2013-03-19 19:35:44 +0100 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2013-03-19 19:39:35 +0100 |
commit | eff59a15d76647ce8282626b9eb463dc3706d56e (patch) | |
tree | f1a6d5583cc68087d351a1d6028d446d95706ec0 | |
parent | 9cd0810f90690a7632d11548ec2e2d9bd8be19de (diff) | |
download | org-mode-eff59a15d76647ce8282626b9eb463dc3706d56e.tar.gz |
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.
-rw-r--r-- | lisp/ox-html.el | 34 |
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. (org-html-format-inline-image - 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) link)) "" - (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)))) (cond @@ -3012,9 +3021,8 @@ contextual information." (t (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)) (alignspec (if (and (boundp 'org-html-format-table-no-css) org-html-format-table-no-css) |