aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Landell <dajva@users.noreply.github.com>2022-01-21 11:15:52 +0100
committerGitHub <noreply@github.com>2022-01-21 10:15:52 +0000
commita8019237a8f5e016a7c952fc2f673a2498a0e779 (patch)
treedbcaeded31f54e1adf7268c240807c3489710a16
parent0bd966ba241a2458d5097e256543eceee50d462c (diff)
Support org-export-custom-protocol-maybe for links (#58)
An example of usage would be the orgit [1] package that supports translating local magit links to some http based repository viewer. 1. https://github.com/magit/orgit
-rw-r--r--ox-jira.el1
-rw-r--r--ox-jira.org1
-rw-r--r--test/ox-jira-test.el18
3 files changed, 19 insertions, 1 deletions
diff --git a/ox-jira.el b/ox-jira.el
index 073753e..ed6320e 100644
--- a/ox-jira.el
+++ b/ox-jira.el
@@ -339,6 +339,7 @@ INFO is a plist holding contextual information. See
(if desc (concat "#" desc) (concat "#" raw-path)))
((string-prefix-p "*" raw-path)
(concat "#" (seq-subseq raw-path 1)))
+ ((org-export-custom-protocol-maybe link desc 'jira info))
(t raw-path))))
(cond
;; Link with description
diff --git a/ox-jira.org b/ox-jira.org
index c0c4d53..8130661 100644
--- a/ox-jira.org
+++ b/ox-jira.org
@@ -562,6 +562,7 @@ INFO is a plist holding contextual information. See
(if desc (concat "#" desc) (concat "#" raw-path)))
((string-prefix-p "*" raw-path)
(concat "#" (seq-subseq raw-path 1)))
+ ((org-export-custom-protocol-maybe link desc 'jira info))
(t raw-path))))
(cond
;; Link with description
diff --git a/test/ox-jira-test.el b/test/ox-jira-test.el
index 3cbaffd..b042495 100644
--- a/test/ox-jira-test.el
+++ b/test/ox-jira-test.el
@@ -22,8 +22,11 @@
;;; Code:
(require 'ert)
+(require 'org-element)
(require 'ox)
(require 'ox-jira)
+(eval-when-compile
+ (require 'cl-lib))
(defun to-jira (string)
(org-export-string-as string 'jira nil '(:src-collapse-threshold 3)))
@@ -144,7 +147,20 @@ h1. {color:red}{{TODO}}{color} This is another headline {color:blue}{{:FOO:BAR:}
(should (equal "see [This Thing|#This Thing] for details\n"
(to-jira "see [[#Heading Name][This Thing]] for details")))
(should (equal "contact [User Name|~accountid:accountid] for details\n"
- (to-jira "contact [[~accountid:accountid][User Name]] for details\n"))))
+ (to-jira "contact [[~accountid:accountid][User Name]] for details\n")))
+ (cl-letf (((symbol-function #'org-export-custom-protocol-maybe)
+ (lambda (link &rest _)
+ (let ((path (org-element-property :path link)))
+ (if (string-prefix-p "example-protocol:" path)
+ "http://example.com"
+ nil)))))
+ (should (equal "fi [http://example.com] fo\n"
+ (to-jira "fi [[example-protocol:example.net]] fo")))
+ (should (equal "fi [Example|http://example.com] fo\n"
+ (to-jira "fi [[example-protocol:example.net][Example]] fo")))
+ (should (not (equal "fi [Example|[http://example.com] fo\n"
+ (to-jira "fi [[unsupported-protocol:example.net][Example]] fo"))))))
+
;; Check that text in paragraphs does not have hard newlines.
;;
(ert-deftest ox-jira-test/paragraphs ()