|
@@ -385,20 +385,28 @@ channel."
|
|
|
|
|
|
;;;; Link
|
|
|
|
|
|
-(defun org-md-link (link contents info)
|
|
|
+(defun org-md-link (link desc info)
|
|
|
"Transcode LINE-BREAK object into Markdown format.
|
|
|
-CONTENTS is the link's description. INFO is a plist used as
|
|
|
-a communication channel."
|
|
|
- (let ((link-org-files-as-md
|
|
|
- (lambda (raw-path)
|
|
|
- ;; Treat links to `file.org' as links to `file.md'.
|
|
|
- (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)))
|
|
|
+DESC is the description part of the link, or the empty string.
|
|
|
+INFO is a plist holding contextual information. See
|
|
|
+`org-export-data'."
|
|
|
+ (let* ((link-org-files-as-md
|
|
|
+ (lambda (raw-path)
|
|
|
+ ;; Treat links to `file.org' as links to `file.md'.
|
|
|
+ (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))
|
|
|
+ (raw-path (raw-path (org-element-property :path link)))
|
|
|
+ (path (cond
|
|
|
+ ((member type '("http" "https" "ftp" "mailto"))
|
|
|
+ (concat type ":" path))
|
|
|
+ ((string= type "file")
|
|
|
+ (org-export-file-uri (funcall link-org-files-as-md raw-path)))
|
|
|
+ (t raw-path))))
|
|
|
(cond
|
|
|
;; Link type is handled by a special function.
|
|
|
- ((org-export-custom-protocol-maybe link contents 'md))
|
|
|
+ ((org-export-custom-protocol-maybe link desc 'md))
|
|
|
((member type '("custom-id" "id" "fuzzy"))
|
|
|
(let ((destination (if (string= type "fuzzy")
|
|
|
(org-export-resolve-fuzzy-link link info)
|
|
@@ -406,13 +414,13 @@ a communication channel."
|
|
|
(pcase (org-element-type destination)
|
|
|
(`plain-text ; External file.
|
|
|
(let ((path (funcall link-org-files-as-md destination)))
|
|
|
- (if (not contents) (format "<%s>" path)
|
|
|
- (format "[%s](%s)" contents path))))
|
|
|
+ (if (not desc) (format "<%s>" path)
|
|
|
+ (format "[%s](%s)" desc path))))
|
|
|
(`headline
|
|
|
(format
|
|
|
"[%s](#%s)"
|
|
|
;; Description.
|
|
|
- (cond ((org-string-nw-p contents))
|
|
|
+ (cond ((org-string-nw-p desc))
|
|
|
((org-export-numbered-headline-p destination info)
|
|
|
(mapconcat #'number-to-string
|
|
|
(org-export-get-headline-number destination info)
|
|
@@ -435,10 +443,9 @@ a communication channel."
|
|
|
description
|
|
|
(org-export-get-reference destination info))))))))
|
|
|
((org-export-inline-image-p link org-html-inline-image-rules)
|
|
|
- (let ((path (let ((raw-path (org-element-property :path link)))
|
|
|
- (cond ((not (equal "file" type)) (concat type ":" raw-path))
|
|
|
- ((not (file-name-absolute-p raw-path)) raw-path)
|
|
|
- (t (expand-file-name raw-path)))))
|
|
|
+ (let ((path (cond ((not (equal "file" type)) (concat type ":" raw-path))
|
|
|
+ ((not (file-name-absolute-p raw-path)) raw-path)
|
|
|
+ (t (expand-file-name raw-path))))
|
|
|
(caption (org-export-data
|
|
|
(org-export-get-caption
|
|
|
(org-export-get-parent-element link)) info)))
|
|
@@ -446,20 +453,11 @@ 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)))
|
|
|
- (format (org-export-get-coderef-format ref contents)
|
|
|
- (org-export-resolve-coderef ref info))))
|
|
|
- ((equal type "radio") contents)
|
|
|
- (t (let* ((raw-path (org-element-property :path link))
|
|
|
- (path
|
|
|
- (cond
|
|
|
- ((member type '("http" "https" "ftp" "mailto"))
|
|
|
- (concat type ":" raw-path))
|
|
|
- ((string= type "file")
|
|
|
- (org-export-file-uri (funcall link-org-files-as-md raw-path)))
|
|
|
- (t raw-path))))
|
|
|
- (if (not contents) (format "<%s>" path)
|
|
|
- (format "[%s](%s)" contents path)))))))
|
|
|
+ (format (org-export-get-coderef-format path desc)
|
|
|
+ (org-export-resolve-coderef path info)))
|
|
|
+ ((equal type "radio") desc)
|
|
|
+ (t (if (not desc) (format "<%s>" path)
|
|
|
+ (format "[%s](%s)" desc path))))))
|
|
|
|
|
|
|
|
|
;;;; Node Property
|