From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Lechtenboerger Subject: PATCH: Extract HTML attributes from link if present Date: Sat, 08 Dec 2018 17:12:08 +0100 Message-ID: <87zhtgf15z.fsf@informationelle-selbstbestimmung-im-internet.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVfDI-0002fS-8v for emacs-orgmode@gnu.org; Sat, 08 Dec 2018 11:12:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVfDF-00016E-5z for emacs-orgmode@gnu.org; Sat, 08 Dec 2018 11:12:20 -0500 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]:34156) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gVfDD-0000s1-NT for emacs-orgmode@gnu.org; Sat, 08 Dec 2018 11:12:16 -0500 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 59120446B2 for ; Sat, 8 Dec 2018 17:12:11 +0100 (CET) Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id Y6Bx55V7bya0 for ; Sat, 8 Dec 2018 17:12:10 +0100 (CET) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi there, for HTML export, attributes are added to links with what is called a =E2=80=9CHACK=E2=80=9D in a comment in ox-html.el: Attribute :attr_html is = read from the parent, to be transferred to the first link. That mechanism can used to assign attributes to the first link in each paragraph/sentence. For org-reveal, I would like to assign computed classes to links in general (several per paragraph). The attached patch extends the current functionality to add attributes of the link to those of the parent. Could that please be included? Best wishes Jens --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ox-html.el-Export-attributes-specified-with-attr_htm.patch >From 3ac50ac3a3c8951d59a1d30b047ae0407731b789 Mon Sep 17 00:00:00 2001 From: Jens Lechtenboerger Date: Sat, 8 Dec 2018 16:44:06 +0100 Subject: [PATCH] ox-html.el: Export attributes specified with :attr_html for links * lisp/ox-html.el (org-html-link): Export :attr_html from link --- lisp/ox-html.el | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 6a81be126..bbe38d8e2 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -3045,19 +3045,25 @@ INFO is a plist holding contextual information. See "#" (org-publish-resolve-external-link option path t)))))) (t raw-path))) - ;; Extract attributes from parent's paragraph. HACK: Only do - ;; this for the first link in parent (inner image link for - ;; inline images). This is needed as long as attributes - ;; cannot be set on a per link basis. (attributes-plist - (let* ((parent (org-export-get-parent-element link)) - (link (let ((container (org-export-get-parent link))) - (if (and (eq (org-element-type container) 'link) - (org-html-inline-image-p link info)) - container - link)))) - (and (eq (org-element-map parent 'link 'identity info t) link) - (org-export-read-attribute :attr_html parent)))) + (org-combine-plists + ;; Extract attributes from parent's paragraph. HACK: Only do + ;; this for the first link in parent (inner image link for + ;; inline images). This is needed as long as attributes + ;; cannot be set on a per link basis. + (let* ((parent (org-export-get-parent-element link)) + (link (let ((container (org-export-get-parent link))) + (if (and (eq (org-element-type container) 'link) + (org-html-inline-image-p link info)) + container + link)))) + (and (eq (org-element-map parent 'link 'identity info t) link) + (org-export-read-attribute :attr_html parent))) + ;; Also add attributes from link itself. Currently, those need + ;; to be added programmatically before org-html-link is invoked, + ;; for example, by backends building upon HTML export, such as + ;; org-reveal. + (org-export-read-attribute :attr_html link))) (attributes (let ((attr (org-html--make-attribute-string attributes-plist))) (if (org-string-nw-p attr) (concat " " attr) "")))) -- 2.17.1 --=-=-=--