emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: "Tarjei Bærland" <tarjeibaerland@gmail.com>
Cc: org-mode-email <emacs-orgmode@gnu.org>
Subject: Re: "org-link-set-parameters" get parent properties
Date: Thu, 31 Jan 2019 09:12:54 -0500	[thread overview]
Message-ID: <CAJ51EToPXSEHmGtEQ3tbTFzojPYFfFh=eioDitNWACEWRp7avw@mail.gmail.com> (raw)
In-Reply-To: <CAJ+-Syy5zqxdHKS4A2oWTxAhLbiiHoUDJ3Xc5SA+UC-QSisSHA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2195 bytes --]

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
@johnkitchin
http://kitchingroup.cheme.cmu.edu



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

[-- Attachment #2: Type: text/html, Size: 3649 bytes --]

      reply	other threads:[~2019-01-31 14:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31 10:36 "org-link-set-parameters" get parent properties Tarjei Bærland
2019-01-31 14:12 ` John Kitchin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJ51EToPXSEHmGtEQ3tbTFzojPYFfFh=eioDitNWACEWRp7avw@mail.gmail.com' \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=tarjeibaerland@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).