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 14:37:33 -0500 Message-ID: <8761o4714y.fsf@alphaville.bos.redhat.com> References: <530AAA84.3000402@gmail.com> <87ob1xgl5e.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WI1Lf-0005Ym-Ps for emacs-orgmode@gnu.org; Mon, 24 Feb 2014 14:38:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WI1LZ-0002wD-2U for emacs-orgmode@gnu.org; Mon, 24 Feb 2014 14:37:55 -0500 Received: from plane.gmane.org ([80.91.229.3]:55185) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WI1LY-0002vu-RV for emacs-orgmode@gnu.org; Mon, 24 Feb 2014 14:37:48 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WI1LT-000798-Sc for emacs-orgmode@gnu.org; Mon, 24 Feb 2014 20:37:43 +0100 Received: from nat-pool-bos-t.redhat.com ([66.187.233.206]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 24 Feb 2014 20:37:43 +0100 Received: from ndokos by nat-pool-bos-t.redhat.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 24 Feb 2014 20:37:43 +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 Nicolas, can you take a look at this patch? If it looks OK, I can push it to maint. --8<---------------cut here---------------start------------->8--- commit f820173bf514549134e8ba10bbbba1e539cb89f6 Author: Nick Dokos Date: Mon Feb 24 14:31:33 2014 -0500 Add handling of user-defined custom links to org-md-link * ox-md.el (org-md-link): Add code to handle user-defined custom links. Refactor raw-path calculation to simplify the code. Reported by John Peloquin (http://thread.gmane.org/gmane.emacs.orgmode/82627) diff --git a/lisp/ox-md.el b/lisp/ox-md.el index 39843d5..fbc5d6f 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -278,7 +278,8 @@ a communication channel." (if (string= ".org" (downcase (file-name-extension raw-path "."))) (concat (file-name-sans-extension raw-path) ".md") raw-path)))) - (type (org-element-property :type link))) + (type (org-element-property :type link)) + (raw-path (org-element-property :path link))) (cond ((member type '("custom-id" "id")) (let ((destination (org-export-resolve-id-link link info))) (if (stringp destination) ; External file. @@ -294,9 +295,8 @@ a communication channel." destination info) "."))))))) ((org-export-inline-image-p link org-html-inline-image-rules) - (let ((path (let ((raw-path (org-element-property :path link))) - (if (not (file-name-absolute-p raw-path)) raw-path - (expand-file-name raw-path)))) + (let ((path (if (not (file-name-absolute-p raw-path)) raw-path + (expand-file-name raw-path))) (caption (org-export-data (org-export-get-caption (org-export-get-parent-element link)) info))) @@ -304,7 +304,7 @@ a communication channel." (if (not (org-string-nw-p caption)) path (format "%s \"%s\"" path caption))))) ((string= type "coderef") - (let ((ref (org-element-property :path link))) + (let ((ref raw-path)) (format (org-export-get-coderef-format ref contents) (org-export-resolve-coderef ref info)))) ((equal type "radio") @@ -318,8 +318,11 @@ a communication channel." (when number (if (atom number) (number-to-string number) (mapconcat 'number-to-string number ".")))))))) - (t (let* ((raw-path (org-element-property :path link)) - (path + ;; Link type is handled by a special function. + ((functionp (setq protocol (nth 2 (assoc type org-link-protocols)))) + (funcall protocol raw-path contents 'md)) + + (t (let* ((path (cond ((member type '("http" "https" "ftp")) (concat type ":" raw-path)) --8<---------------cut here---------------end--------------->8--- Thanks, Nick