emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Marc Ihm <marc@ihm.name>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] ox-confluence.el: Handle checkboxes and inactive timestamps correctly
Date: Thu, 02 Mar 2017 20:33:38 +0100	[thread overview]
Message-ID: <86pohziict.fsf@ihm.name> (raw)
In-Reply-To: <87lgspayqu.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 01 Mar 2017 14:54:33 +0100")

[-- Attachment #1: Type: text/plain, Size: 524 bytes --]

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Correcting myselfè
>
> Nicolas Goaziou <mail@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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch for ox-confluence.el --]
[-- Type: text/x-patch, Size: 3455 bytes --]

--- 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)))

  parent reply	other threads:[~2017-03-02 19:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-28 19:08 [PATCH] ox-confluence.el: Handle checkboxes and inactive timestamps correctly Marc Ihm
2017-03-01 13:51 ` Nicolas Goaziou
2017-03-01 13:54   ` Nicolas Goaziou
2017-03-01 20:48     ` Marc Ihm
2017-03-02 19:33     ` Marc Ihm [this message]
2017-03-02 21:16       ` Nicolas Goaziou
2017-03-03 20:50         ` Marc Ihm
2017-03-05 17:41           ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86pohziict.fsf@ihm.name \
    --to=marc@ihm.name \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).