From 8aaf0718e2d43195cc42ff9bbf2b0e0d6eff4bcf Mon Sep 17 00:00:00 2001 From: Aaron Ecay Date: Fri, 8 Mar 2013 13:44:17 -0500 Subject: [PATCH 3/3] Support properties for HTML links * lisp/ox-html.el (org-html-link--inline-image): use link properties in addition to ATTR_HTML ones (org-html--properties-to-attributes): new function (org-html-link): use link properties instead of ATTR_HTML ones Link attributes of the form [[http://test.com/&&key=value]] will be translated to upon export. For image links which are exported inline, the key="value" will be inserted in the img tag. --- lisp/ox-html.el | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 9d5fdc7..fe2e10c 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2405,7 +2405,8 @@ 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) " "))) + (attr (concat (mapconcat #'identity (org-element-property :attr_html parent) " ") + (org-html--properties-to-attributes (org-element-property :properties link))))) ;; Return proper string, depending on DISPOSITION. (org-html-format-inline-image path caption label attr (org-html-standalone-image-p link info)))) @@ -2454,6 +2455,20 @@ standalone images, do the following. (= (incf inline-image-count) 1))) (t nil)))))))) +(defun org-html--properties-to-attributes (properties) + "Convert a plist of link properties to an HTML attribtes string. + +For a plist having the form (:key1 \"value1\" ...), returns a +string of the form \"key1=\\\"value1\\\" ...\"." + (mapconcat #'identity + (loop for key in properties by 'cddr + collect (concat " " + (substring (symbol-name key) 1) + "=\"" + (plist-get properties key) + "\"")) + "")) + (defun org-html-link (link desc info) "Transcode a LINK object from Org to HTML. @@ -2507,24 +2522,9 @@ INFO is a plist holding contextual information. See (mapconcat 'number-to-string numbers "-"))))))))) (t raw-path))) - attributes protocol) - ;; Extract attributes from parent's paragraph. HACK: Only do this - ;; for the first link in parent. This is needed as long as - ;; attributes cannot be set on a per link basis. - (and (setq attributes - (let ((parent (org-export-get-parent-element link))) - (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)) - " ")))) - (unless (string= attributes "") - (setq attributes (concat " " attributes)))) + (properties (org-element-property :properties link)) + (attributes (org-html--properties-to-attributes properties)) + protocol) (cond ;; Image file. ((and (or (eq t org-html-inline-images) -- 1.8.1.5