ox-confluence: Handle checkboxes and inactive timestamps correctly

* contrib/lisp/ox-confluence.el (org-confluence-timestamp): New
  function.
(org-confluence-headline): Use new function.
(org-confluence-table-cell): Add missing space.

Fix handling of square brackets from timestamps and checkboxes; avoid
invalid confluence markup for empty table headers.
This commit is contained in:
Marc Ihm 2017-03-05 18:36:30 +01:00 committed by Nicolas Goaziou
parent 8dfab7be23
commit 1a70061e3f
1 changed files with 23 additions and 10 deletions

View File

@ -56,6 +56,7 @@
(table-cell . org-confluence-table-cell) (table-cell . org-confluence-table-cell)
(table-row . org-confluence-table-row) (table-row . org-confluence-table-row)
(template . org-confluence-template) (template . org-confluence-template)
(timestamp . org-confluence-timestamp)
(underline . org-confluence-underline))) (underline . org-confluence-underline)))
(defcustom org-confluence-lang-alist (defcustom org-confluence-lang-alist
@ -87,14 +88,19 @@
(format "\{\{%s\}\}" contents)) (format "\{\{%s\}\}" contents))
(defun org-confluence-headline (headline contents info) (defun org-confluence-headline (headline contents info)
(let ((low-level-rank (org-export-low-level-p headline info)) (let* ((low-level-rank (org-export-low-level-p headline info))
(text (org-export-data (org-element-property :title headline) (text (org-export-data (org-element-property :title headline)
info)) info))
(level (org-export-get-relative-level headline info))) (todo (org-export-data (org-element-property :todo-keyword headline)
info))
(level (org-export-get-relative-level headline info))
(todo-text (if (or (not (plist-get info :with-todo-keywords))
(string= todo ""))
""
(format "*{{%s}}* " todo))))
;; Else: Standard headline. ;; Else: Standard headline.
(format "h%s. %s\n%s" level text (format "h%s. %s%s\n%s" level todo-text text
(if (org-string-nw-p contents) contents (if (org-string-nw-p contents) contents ""))))
""))))
(defun org-confluence-link (link desc info) (defun org-confluence-link (link desc info)
(let ((raw-link (org-element-property :raw-link link))) (let ((raw-link (org-element-property :raw-link link)))
@ -143,14 +149,21 @@ a communication channel."
(defun org-confluence-table-cell (table-cell contents info) (defun org-confluence-table-cell (table-cell contents info)
(let ((table-row (org-export-get-parent table-cell))) (let ((table-row (org-export-get-parent table-cell)))
(concat (concat
(when (org-export-table-row-starts-header-p table-row info) (and (org-export-table-row-starts-header-p table-row info) "|")
"|") " " contents "|")))
contents "|")))
(defun org-confluence-template (contents info) (defun org-confluence-template (contents info)
(let ((depth (plist-get info :with-toc))) (let ((depth (plist-get info :with-toc)))
(concat (when depth "\{toc\}\n\n") contents))) (concat (when depth "\{toc\}\n\n") contents)))
(defun org-confluence-timestamp (timestamp _contents _info)
"Transcode a TIMESTAMP object from Org to Confluence.
CONTENTS and INFO are ignored."
(let ((translated (org-timestamp-translate timestamp)))
(if (string-prefix-p "[" translated)
(concat "(" (substring translated 1 -1) ")")
translated)))
(defun org-confluence-underline (underline contents info) (defun org-confluence-underline (underline contents info)
(format "+%s+" contents)) (format "+%s+" contents))