From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: "org-link-set-parameters" get parent properties Date: Thu, 31 Jan 2019 09:12:54 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000002aa8af0580c1a09b" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:36058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpD5d-00052D-S7 for emacs-orgmode@gnu.org; Thu, 31 Jan 2019 09:13:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpD5c-0005XD-7E for emacs-orgmode@gnu.org; Thu, 31 Jan 2019 09:13:13 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:37474) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpD5Z-0005WS-S3 for emacs-orgmode@gnu.org; Thu, 31 Jan 2019 09:13:12 -0500 Received: by mail-wr1-x433.google.com with SMTP id s12so3470518wrt.4 for ; Thu, 31 Jan 2019 06:13:09 -0800 (PST) In-Reply-To: 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: =?UTF-8?Q?Tarjei_B=C3=A6rland?= Cc: org-mode-email --0000000000002aa8af0580c1a09b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable One way is through a filter. In the filter function you get an info argument that contains the information you want. I hacked this together and it does add a tooltip to the link, but it is not elegant or obvious, and it does not do any checking for the type of link, whether an attr exists, etc. The gist is that it looks like you can get the parent from the parse-tree info, and get the attr_html info from that (which is a list of strings). Then you have to modify the "data" in the filter function which is the html. It is easy here to just replace the wrote: > Hi! > > I have a custom function for exporting image links in org-mode (I have my > html exported to the parent folder of my .org files, and I just want to > keep one copy of the image files). > > How can I get the "attr_html" of the link for a custom > org-set-link-parameters function? As far as I can tell, the :export wants= a > function taking (path desc backend), and I do not know how to extract the > parent of the link from this. > > Thanks in advance! > > Regards, > Tarjei > --0000000000002aa8af0580c1a09b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
One way is through a filter. In the filte= r function you get an info argument that contains the information you want.= I hacked this together and it does add a tooltip to the link, but it is no= t elegant or obvious, and it does not do any checking for the type of link,= whether an attr exists, etc.=C2=A0

The gist is that it looks like you can get the parent from the pa= rse-tree info, and get the attr_html info from that (which is a list of str= ings). Then you have to modify the "data" in the filter function = which is the html. It is easy here to just replace the <a with <a att= r_html, but a more complex transformation might require something more clev= er.=C2=A0

Maybe this is a = start to get where you want.

the cite link is an org-ref link, but I think this should work on any ki= nd of link.


#+attr_html: title= =3D"I am a tooltip"
cite:schuett-2018-schnet
=

* build=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 :noexport:
#+BEGIN_SRC emacs-lisp
<= div>(defun ox-html-link-filter (data _backend info)
=C2=A0 (let (= (link (car (org-element-map (plist-get info :parse-tree) 'link
=C2=A0 =C2=A0 =C2=A0'identit= y))))
=C2=A0 =C2=A0 (replace-regexp-in-string "<a " = (concat "<a "
<= /span>=C2=A0 =C2=A0 (s-join " " (org-element-property
<= span style=3D"white-space:pre"> :attr_html
(org-element-property :parent link))= )
=C2=A0 =C2=A0 "= ; ")
=C2=A0 =C2=A0= =C2=A0 data)))

(add-to-list 'org-export-filte= r-link-functions 'ox-html-link-filter)
(browse-url (org-html-= export-to-html nil nil nil t))
#+END_SRC




On Thu, J= an 31, 2019 at 5:36 AM Tarjei B=C3=A6rland <tarjeibaerland@gmail.com> wrote:
Hi!

I have a custom function for exporting image links in org-m= ode (I have my html exported to the parent folder of my .org files, and I j= ust want to keep one copy of the image files).

How= can I get the "attr_html" of the link for a custom org-set-link-= parameters function? As far as I can tell, the :export wants a function tak= ing (path desc backend), and I do not know how to extract the parent of the= link from this.

Thanks in advance!

=
Regards,
Tarjei
--0000000000002aa8af0580c1a09b--