Nicolas Goaziou <m...@nicolasgoaziou.fr> writes:

> Correcting myselfè
>
> Nicolas Goaziou <m...@nicolasgoaziou.fr> writes:
>
>>> +  :filters-alist '((:filter-final-output . org-confluence-fix-timestamps))
>>
>> Why do you use a final filter? It is a pretty gross tool, couldn't you
>> simply generate the correct output from the plain-list or item
>> translator?
>
> I meant timestamp translator.

Hi,

this is a corrected patch, which handles timestamps in a more canoncial
way.

Best regards
Marc

--- a/contrib/lisp/ox-confluence.el	2017-03-02 20:10:19.645053100 +0100
+++ b/contrib/lisp/ox-confluence.el	2017-03-02 20:14:57.963701300 +0100
@@ -58,6 +58,7 @@
 		     (table-cell . org-confluence-table-cell)
 		     (table-row . org-confluence-table-row)
 		     (template . org-confluence-template)
+                     (timestamp . org-confluence-timestamp)
 		     (underline . org-confluence-underline)
 		     (verbatim . org-confluence-verbatim)))
 
@@ -81,17 +82,34 @@
 (defun org-confluence-italic (italic contents info)
   (format "_%s_" 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-item (item contents info)
   (let* ((plain-list (org-export-get-parent item))
          (type (org-element-property :type plain-list))
-         (bullet (if (eq type 'ordered) ?\# ?\-)))
-    (concat (make-string (1+ (org-confluence--li-depth item)) bullet)
-            " "
-    (if (eq type 'descriptive)
- (concat "*"
- (org-export-data (org-element-property :tag item) info)
- "* - "))
-            (org-trim contents))))
+	 (depth (1+ (org-confluence--li-depth item)))
+	 (checkbox-possibly (cl-case (org-element-property :checkbox item)
+			      (on "*{{(X)}}* ") 
+			      (off "*{{( )}}* ")
+			      (trans "*{{(\\-)}}* "))))
+    (cl-case plain-list
+      (descriptive
+       (concat (make-string depth ?-) " " checkbox-possibly
+               (org-export-data (org-element-property :tag item) info) ": "
+               (org-trim contents)))
+      (ordered
+       (concat (make-string depth ?#) " " checkbox-possibly
+               (org-trim contents)))
+      (t
+       (concat (make-string depth ?-)
+               " " checkbox-possibly
+               (org-trim contents))))))
 
 (defun org-confluence-fixed-width (fixed-width contents info)
   (org-confluence--block
@@ -106,12 +124,18 @@
   (format "\{\{%s\}\}" (org-element-property :value code)))
 
 (defun org-confluence-headline (headline contents info)
-  (let ((low-level-rank (org-export-low-level-p headline info))
-        (text (org-export-data (org-element-property :title headline)
-                               info))
-        (level (org-export-get-relative-level headline info)))
-    ;; Else: Standard headline.
-    (format "h%s. %s\n%s" level text
+  (let* ((low-level-rank (org-export-low-level-p headline info))
+	 (text (org-export-data (org-element-property :title 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))))
+    
+    (format "h%s. %s%s\n%s" level todo-text text
             (if (org-string-nw-p contents) contents
               ""))))
 
@@ -167,7 +191,7 @@
     (concat
      (when (org-export-table-row-starts-header-p table-row info)
        "|")
-     contents "|")))
+     " " contents " |")))
 
 (defun org-confluence-template (contents info)
   (let ((depth (plist-get info :with-toc)))

Reply via email to