From: John Kitchin <johnrkitchin@gmail.com>
To: Nick Dokos <ndokos@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: org export to org
Date: Thu, 29 Jan 2015 09:17:39 -0500 [thread overview]
Message-ID: <m2386tsmbg.fsf@gmail.com> (raw)
In-Reply-To: <87pp9yfc0h.fsf@pierrot.dokosmarshall.org>
Thanks for the tip.
Today what I tried for this worked fine. This will export an org file to
an org file, but transform all the cite type links into pandoc format,
including pre/post text if you put that in the link description with ::
as a separator. Then you could run that org file through pandoc. It
looks like this would work for any export that can use pandoc citations,
with a simple redefinition of the derived backend.
#+BEGIN_SRC emacs-lisp
(defun pandoc-cite-format (link contents info)
(if (-contains? org-ref-cite-types (org-element-property :type link))
(cond
;; link with description
((org-element-property :contents-begin link)
(let* ((contents (buffer-substring
(org-element-property :contents-begin link)
(org-element-property :contents-end link)))
(split (split-string contents "::"))
(pre-text (nth 0 split))
(post-text (nth 1 split)))
(concat
"[@" (org-element-property :path link)
(when pre-text (concat ", " pre-text))
(when post-text (concat ", " post-text))
"]"
)
))
;; plain citations
(t
(concat "["
(mapconcat (lambda (key) (concat "@" key))
(split-string (org-element-property :path link) ",")
"; ")
"]")))
;; not a cite link. just return the original link
(org-org-identity link contents info)))
(org-export-define-derived-backend 'pandoc-org 'org
:translate-alist '((link . pandoc-cite-format)))
(find-file (org-export-to-file 'pandoc-org "org-to-org.org"))
#+END_SRC
Nick Dokos writes:
> John Kitchin <johnrkitchin@gmail.com> writes:
>
>> All the discussion about citations has gotten me thinking. It is easy
>> enough to export cite links to the pandoc format, including pre and post
>> text. I have done a proof of concept of this in a markdown export.
>>
>> I would like to do an org export to org, with the goal of the exported
>> org document to no longer have cite:KEY1,KEY2 but rather [@KEY1; @KEY2]. So far my
>> investigations of exporting org to org have not led anywhere; the links are
>> untouched, even with an org format option in the link definition.
>>
>> Are links ignored in an org export to org? If not, is there some trick
>> to converting them to another format?
>>
>
> ox-org.el defines the org backend with (link . org-org-identity) -
> actually just about everything is tied to org-org-identity (with a few
> exceptions of course). Maybe you can derive a backend which munges links
> appropriately (for some value of "appropriately")?
--
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
next prev parent reply other threads:[~2015-01-29 14:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-28 22:43 org export to org John Kitchin
2015-01-29 4:26 ` Nick Dokos
2015-01-29 14:17 ` John Kitchin [this message]
2015-01-29 18:34 ` Nicolas Goaziou
2015-01-29 22:00 ` John Kitchin
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=m2386tsmbg.fsf@gmail.com \
--to=johnrkitchin@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=ndokos@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).