From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marc Ihm Subject: Re: [PATCH] ox-confluence.el: Handle checkboxes and inactive timestamps correctly Date: Thu, 02 Mar 2017 20:33:38 +0100 Message-ID: <86pohziict.fsf@ihm.name> References: <8660ju2kx4.fsf@ihm.name> <87tw7dayw4.fsf@nicolasgoaziou.fr> <87lgspayqu.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjWU2-00012B-DI for emacs-orgmode@gnu.org; Thu, 02 Mar 2017 14:33:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjWTy-0002Kw-9U for emacs-orgmode@gnu.org; Thu, 02 Mar 2017 14:33:50 -0500 Received: from smtp04.udag.de ([62.146.106.30]:60682) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cjWTx-0002K4-Vl for emacs-orgmode@gnu.org; Thu, 02 Mar 2017 14:33:46 -0500 In-Reply-To: <87lgspayqu.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 01 Mar 2017 14:54:33 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Nicolas Goaziou writes: > Correcting myself=C3=A8 > > Nicolas Goaziou writes: > >>> + :filters-alist '((:filter-final-output . org-confluence-fix-timestam= ps)) >> >> 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=ox-confluence.patch Content-Description: patch for ox-confluence.el Content-Transfer-Encoding: quoted-printable --- 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))) =20 @@ -81,17 +82,34 @@ (defun org-confluence-italic (italic contents info) (format "_%s_" contents)) =20 +(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)}}* ")=20 + (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)))))) =20 (defun org-confluence-fixed-width (fixed-width contents info) (org-confluence--block @@ -106,12 +124,18 @@ (format "\{\{%s\}\}" (org-element-property :value code))) =20 (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=3D todo "")) + "" + (format "*{{%s}}* " todo)))) + =20 + (format "h%s. %s%s\n%s" level todo-text text (if (org-string-nw-p contents) contents "")))) =20 @@ -167,7 +191,7 @@ (concat (when (org-export-table-row-starts-header-p table-row info) "|") - contents "|"))) + " " contents " |"))) =20 (defun org-confluence-template (contents info) (let ((depth (plist-get info :with-toc))) --=-=-=--