Skip to content

Commit

Permalink
First try to transcode LINK objects with a 'pandoc specific translator.
Browse files Browse the repository at this point in the history
Fallback to a translator for 'org export if one is not found.

This is specifically to improve interoperability with `org-ref'
(https://github.com/jkitchin/org-ref), which would otherwise reformat
citation links (cite:<reference name>) into a form that breaks pandoc.
  • Loading branch information
Lixin Chin committed Nov 1, 2016
1 parent b401c0f commit 479ce18
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ox-pandoc.el
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@
:type 'list)

(org-export-define-derived-backend 'pandoc 'org
:translate-alist '((template . org-pandoc-template)
:translate-alist '((link . org-pandoc-link)
(template . org-pandoc-template)
(paragraph . org-pandoc-identity))
;; :export-block "PANDOC"
:menu-entry
Expand Down Expand Up @@ -1246,6 +1247,16 @@ t means output to buffer."
(concat (make-temp-name ".tmp") ".org") s)
a s v b e (lambda (f) (org-pandoc-run-to-buffer-or-file f format s buf-or-open))))

(defun org-pandoc-link (link contents info)
"Transcode LINK object using the registered formatter for the
'pandoc backend. If none exists, transcode using the registered
formatter for the 'org export backend. CONTENTS is the
description of the link, as a string, or nil. INFO is a plist
containing current export state."
(or (org-export-custom-protocol-maybe link contents 'pandoc)
(org-export-custom-protocol-maybe link contents 'org)
(org-element-link-interpreter link contents)))

(defun org-pandoc-template (contents info)
"Template processor for CONTENTS and INFO.
Option table is created in this stage."
Expand Down

0 comments on commit 479ce18

Please sign in to comment.