John Peloquin <john.peloq...@gmail.com> writes: > Greetings, > > I'm trying to define a custom link in org mode with custom export > formatting, but I get unexpected results when exporting to markdown. > > > Minimal example: > > `minimal-init.el` > > (add-to-list 'load-path "~/.emacs.d/elpa/org-20140217") > (require 'org) > (add-to-list 'org-export-backends "md") > > (org-add-link-type > "cite" nil > (lambda (path desc format) > (format "[@%s]" path))) > > > `minimal.org` > > Some text [[cite:citekey]]. > > > When I export `minimal.org` to markdown using C-c C-e m M, I get: > > Some text <citekey>. > > > Whereas I expected: > > Some text [@citekey]. > > > I tried this with a clean emacs configuration (`emacs -Q -l > minimal-init.el`). `org-version` returns 8.2.5h, which as far as I > know is the latest version. `emacs-version` is 24.3.1. > > I do get the expected export result if I export to latex or html, so > the link export definition in init.el does work. Am I doing something > wrong?
No. > Is this a bug in ox-md? > Yes. There is no provision for handling user-defined link types. Try the following patch: --8<---------------cut here---------------start------------->8--- diff --git a/lisp/ox-md.el b/lisp/ox-md.el index b8316dd..fa64f2d 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -340,6 +340,10 @@ a communication channel." (when number (if (atom number) (number-to-string number) (mapconcat 'number-to-string number ".")))))))) + ;; Link type is handled by a special function. + ((functionp (setq protocol (nth 2 (assoc type org-link-protocols)))) + (funcall protocol (org-element-property :path link) contents 'md)) + (t (let* ((raw-path (org-element-property :path link)) (path (cond --8<---------------cut here---------------end--------------->8--- Lightly tested with your reproducer - thanks for providing one! -- Nick