From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: custom link export and ox-md Date: Mon, 24 Feb 2014 00:00:29 -0500 Message-ID: <87ob1xgl5e.fsf@gmail.com> References: <530AAA84.3000402@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHnex-00009Z-Kn for emacs-orgmode@gnu.org; Mon, 24 Feb 2014 00:01:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WHneo-00088M-2P for emacs-orgmode@gnu.org; Mon, 24 Feb 2014 00:00:55 -0500 Received: from plane.gmane.org ([80.91.229.3]:41597) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHnen-00087e-S7 for emacs-orgmode@gnu.org; Mon, 24 Feb 2014 00:00:45 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WHnek-0005IV-El for emacs-orgmode@gnu.org; Mon, 24 Feb 2014 06:00:42 +0100 Received: from pool-98-110-160-12.bstnma.fios.verizon.net ([98.110.160.12]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 24 Feb 2014 06:00:42 +0100 Received: from ndokos by pool-98-110-160-12.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 24 Feb 2014 06:00:42 +0100 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: emacs-orgmode@gnu.org John Peloquin 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 . > > > 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