emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] "org-link-set-parameters" get parent properties


From: John Kitchin
Subject: Re: [O] "org-link-set-parameters" get parent properties
Date: Thu, 31 Jan 2019 09:12:54 -0500

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 <a with <a attr_html, but a more complex transformation might require something more clever. 

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 kind of link.


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


* build                                                            :noexport:
#+BEGIN_SRC emacs-lisp
(defun ox-html-link-filter (data _backend info)
  (let ((link (car (org-element-map (plist-get info :parse-tree) 'link
     'identity))))
    (replace-regexp-in-string "<a " (concat "<a "
    (s-join " " (org-element-property
:attr_html
(org-element-property :parent link)))
    " ")
      data)))

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



John

-----------------------------------
Professor John Kitchin 
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803


On Thu, Jan 31, 2019 at 5:36 AM Tarjei Bærland <address@hidden> 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]