emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Daimrod <daimrod@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Help on org-export-filter-link-functions
Date: Sat, 04 Oct 2014 12:40:41 -0400	[thread overview]
Message-ID: <m2d2a7n5yu.fsf@andrew.cmu.edu> (raw)
In-Reply-To: <87lhox2yf0.fsf@tanger.home> (daimrod@gmail.com's message of "Fri, 03 Oct 2014 13:19:31 +0200")

Daimrod <daimrod@gmail.com> writes:

Why don't you just define how the link should be exported in your link
definition?

for example:
https://github.com/jkitchin/jmax/blob/master/org/org-ref.org#the-links

You can see a link that is defined, with different export formats for
different backends.

I am intrigued by your function! It does not seem to work for all types
of links though, for example I tried on on some file links,
e.g. file:bib.bib, and [[file.bib]], but these fall in the (t data)
case. [[file:bib.bib][bibliography]] on the other hand gets handled and
you can access the element properties. 

I tried a similar approach on a table, but it did not work as I
expected. Apparently the next property change puts you in a table-cell,
rather than the parent table.

I too am wondering if there is a defined way to get to the element
properties within a filter function. For example, in this post
http://kitchingroup.cheme.cmu.edu/blog/2014/09/22/Showing-what-data-went-into-a-code-block-on-export/
I concocted a preprocess scheme to get a list of table names, and then a
filter function to put the names in the export on each table. It would
be much more elegant to get it directly from the table element somehow.




> Hi,
>
> I've wrote a simple filter to customize how links are exported in
> latex:
>
> #+BEGIN_SRC
> (defun dmd--latex-bib-link-filter (data backend info)
>   "Convert a bib link to a citation (e.g. bib:foo93 -> \cite{foo93})."
>   (let* ((beg (next-property-change 0 data))
>          (link (if beg (get-text-property beg :parent data))))
>     (cond ((and link
>                 (org-export-derived-backend-p backend 'latex)
>                 (string= (org-element-property :type link) "bib"))
>            (format "\\cite{%s}" (org-element-property :path link)))
>           ((and link
>                 (org-export-derived-backend-p backend 'latex)
>                 (string= (org-element-property :type link) "file")
>                 (string= (org-element-property :path link) "~/.bib.bib"))
>            (format "\\cite{%s}" (org-element-property :search-option link)))
>           (t data))))
> #+END_SRC
>
> And I was wondering whether there is an easier way to retrieve the org
> properties stored in the text properties of DATA.
>
> Best,

-- 
-----------------------------------
John Kitchin
Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu

  reply	other threads:[~2014-10-04 16:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03 11:19 Help on org-export-filter-link-functions Daimrod
2014-10-04 16:40 ` John Kitchin [this message]
2014-10-05  1:13   ` Rasmus
2014-10-05 13:11     ` John Kitchin
2014-10-05 22:24       ` Rasmus

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=m2d2a7n5yu.fsf@andrew.cmu.edu \
    --to=jkitchin@andrew.cmu.edu \
    --cc=daimrod@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).