aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Brautaset <stig@brautaset.org>2020-09-20 11:53:40 +0100
committerStig Brautaset <stig@brautaset.org>2020-09-20 12:00:09 +0100
commit02a6e2a1426d6062832ea0e8ed5aad85e936119d (patch)
treea037e56c53be7651e73f3f40aaac4dfa893e50c2
parent41f65819c7c207279358e8a5395f5d7f8ea9c747 (diff)
Allow overriding headline relative headline levels
-rw-r--r--ox-jira.el18
-rw-r--r--ox-jira.org24
-rw-r--r--test/ox-jira-test.el11
3 files changed, 49 insertions, 4 deletions
diff --git a/ox-jira.el b/ox-jira.el
index f8dd2c9..3846762 100644
--- a/ox-jira.el
+++ b/ox-jira.el
@@ -89,6 +89,17 @@
:group 'ox-export-jira
:type '(list))
+(defcustom ox-jira-override-headline-offset nil
+ "Use this to override the (default) relative headline levels.
+
+If you want to have the headings *real* heading level in
+the Jira output when you export a subsection, use `0' here.
+
+If you think the headings in Jira are too big by default, you
+could set this to `2' to start headings at level 3."
+ :group 'ox-export-jira
+ :type 'integer)
+
;;; Defining Backend
(org-export-define-backend 'jira
@@ -239,8 +250,11 @@ information."
"Transcode a HEADLINE element from Org to JIRA.
CONTENTS is the contents of the headline, as a string. INFO is
the plist used as a communication channel."
- (let* ((level (org-export-get-relative-level headline info))
- (title (org-export-data-with-backend
+ (let* ((headline-info (if (eql ox-jira-override-headline-offset nil)
+ info
+ (plist-put nil :headline-offset ox-jira-override-headline-offset)))
+ (level (org-export-get-relative-level headline headline-info))
+ (title (org-export-data-with-backend
(org-element-property :title headline)
'jira info))
(todo (and (plist-get info :with-todo-keywords)
diff --git a/ox-jira.org b/ox-jira.org
index 0717f31..a39c81e 100644
--- a/ox-jira.org
+++ b/ox-jira.org
@@ -173,6 +173,23 @@ JIRA supports formatting for these languages:
:type '(list))
#+end_src
+*** Override export heading levels
+
+You can pass options to the org-exporter backend.
+
+#+begin_src emacs-lisp
+(defcustom ox-jira-override-headline-offset nil
+ "Use this to override the (default) relative headline levels.
+
+If you want to have the headings *real* heading level in
+the Jira output when you export a subsection, use `0' here.
+
+If you think the headings in Jira are too big by default, you
+could set this to `2' to start headings at level 3."
+ :group 'ox-export-jira
+ :type 'integer)
+#+end_src
+
** Define Backend
This is the entry point of our package. The first argument is the name
@@ -416,8 +433,11 @@ That's a bit weird, but there you go.
"Transcode a HEADLINE element from Org to JIRA.
CONTENTS is the contents of the headline, as a string. INFO is
the plist used as a communication channel."
- (let* ((level (org-export-get-relative-level headline info))
- (title (org-export-data-with-backend
+ (let* ((headline-info (if (eql ox-jira-override-headline-offset nil)
+ info
+ (plist-put nil :headline-offset ox-jira-override-headline-offset)))
+ (level (org-export-get-relative-level headline headline-info))
+ (title (org-export-data-with-backend
(org-element-property :title headline)
'jira info))
(todo (and (plist-get info :with-todo-keywords)
diff --git a/test/ox-jira-test.el b/test/ox-jira-test.el
index 293095d..168a40d 100644
--- a/test/ox-jira-test.el
+++ b/test/ox-jira-test.el
@@ -90,6 +90,17 @@ h3. third level
** second level
*** third level"))))
+;; Override headline offset
+;;
+(ert-deftest ox-jira-test/headlines-with-customized-levels ()
+ (let ((ox-jira-override-headline-offset 2))
+ (should (equal "h3. top level
+h4. second level
+h5. third level
+" (to-jira "* top level
+** second level
+*** third level")))))
+
(ert-deftest ox-jira-test/todo-headlines ()
(should