ox-md: Fix fuzzy link export

* lisp/ox-md.el (org-md-link): Fix fuzzy link export.
This commit is contained in:
Nicolas Goaziou 2015-09-09 14:04:36 +02:00
parent 9600ce5f96
commit 790bd6458b
1 changed files with 19 additions and 18 deletions

View File

@ -301,12 +301,11 @@ channel."
CONTENTS is the link's description. INFO is a plist used as CONTENTS is the link's description. INFO is a plist used as
a communication channel." a communication channel."
(let ((link-org-files-as-md (let ((link-org-files-as-md
(function (lambda (raw-path)
(lambda (raw-path) ;; Treat links to `file.org' as links to `file.md'.
;; Treat links to `file.org' as links to `file.md'. (if (string= ".org" (downcase (file-name-extension raw-path ".")))
(if (string= ".org" (downcase (file-name-extension raw-path "."))) (concat (file-name-sans-extension raw-path) ".md")
(concat (file-name-sans-extension raw-path) ".md") raw-path)))
raw-path))))
(type (org-element-property :type link))) (type (org-element-property :type link)))
(cond (cond
;; Link type is handled by a special function. ;; Link type is handled by a special function.
@ -344,18 +343,20 @@ a communication channel."
(org-export-resolve-coderef ref info)))) (org-export-resolve-coderef ref info))))
((equal type "radio") contents) ((equal type "radio") contents)
((equal type "fuzzy") ((equal type "fuzzy")
(let ((destination (org-export-resolve-fuzzy-link link info))) (let* ((destination (org-export-resolve-fuzzy-link link info))
(if (org-string-nw-p contents) contents (description
(when destination (or (org-string-nw-p contents)
(let ((number (org-export-get-ordinal destination info))) (let ((number (org-export-get-ordinal destination info)))
(if number (cond
(if (atom number) (number-to-string number) ((not number)
(mapconcat #'number-to-string number ".")) (and (eq 'headline (org-element-type destination))
;; Unnumbered headline. (org-export-data
(and (eq 'headline (org-element-type destination)) (org-element-property :title destination) info)))
;; BUG: shouldn't headlines have a form like [ref](name) in md? ((atom number) (number-to-string number))
(org-export-data (t (mapconcat #'number-to-string number ".")))))))
(org-element-property :title destination) info)))))))) (format "[%s](%s)"
description
(org-export-get-reference destination info))))
(t (let* ((raw-path (org-element-property :path link)) (t (let* ((raw-path (org-element-property :path link))
(path (path
(cond (cond