From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: org export to org Date: Thu, 29 Jan 2015 09:17:39 -0500 Message-ID: References: <87pp9yfc0h.fsf@pierrot.dokosmarshall.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGpuk-0001E6-1M for emacs-orgmode@gnu.org; Thu, 29 Jan 2015 09:17:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGpug-0000NF-No for emacs-orgmode@gnu.org; Thu, 29 Jan 2015 09:17:45 -0500 Received: from mail-qg0-x232.google.com ([2607:f8b0:400d:c04::232]:49555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGpug-0000N9-Ie for emacs-orgmode@gnu.org; Thu, 29 Jan 2015 09:17:42 -0500 Received: by mail-qg0-f50.google.com with SMTP id f51so28532176qge.9 for ; Thu, 29 Jan 2015 06:17:42 -0800 (PST) In-reply-to: <87pp9yfc0h.fsf@pierrot.dokosmarshall.org> 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nick Dokos Cc: emacs-orgmode@gnu.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 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