emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Charles Durst <cwdurst+orgmode@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] ox-confluence.el: Better list item support
Date: Mon, 5 Dec 2016 18:44:25 -0500	[thread overview]
Message-ID: <CAM4wePiAufQeEtBwmC24AouyJtqAiDMc0C-D8sKTengi1k-O8g@mail.gmail.com> (raw)

One more.  Hopefully more interesting than my last one.

--
Charles Durst
cwdurst+orgmode@gmail.com


* contrib/lisp/ox-confluence.el (org-confluence--li-bullet,
  org-confluence-item): Use "#" for ordered lists, include item
  name in descriptive lists.

This correctly handles nested lists including mixes of ordered,
unordered and descriptive lists.

TINYCHANGE
---
 contrib/lisp/ox-confluence.el | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/contrib/lisp/ox-confluence.el b/contrib/lisp/ox-confluence.el
index 48bc5ea..78dc7f4 100644
--- a/contrib/lisp/ox-confluence.el
+++ b/contrib/lisp/ox-confluence.el
@@ -79,7 +79,7 @@
   (format "_%s_" contents))

 (defun org-confluence-item (item contents info)
-  (concat (make-string (1+ (org-confluence--li-depth item)) ?\-)
+  (concat (org-confluence--li-bullet item)
           " "
           (org-trim contents)))

@@ -161,21 +161,27 @@ a communication channel."
           contents
           "\{code\}\n"))

-(defun org-confluence--li-depth (item)
-  "Return depth of a list item; -1 means not a list item"
-  ;; FIXME check whether it's worth it to cache depth
+(defun org-confluence--li-bullet (item)
+  "Return the bullet of a list item; \"\" means not a list item"
+  ;; FIXME check whether it's worth it to cache the bullet
   ;;       (it gets recalculated quite a few times while
   ;;       traversing a list)
-  (let ((depth -1)
+  (let ((bullet "")
+ (list-type (org-element-property :type (org-export-get-parent item)))
         (tag))
+    (if (eq list-type 'descriptive)
+ (setq bullet (concat " *"
+     (org-export-data (org-element-property :tag item) info)
+     "* - ")))
     (while (and item
                 (setq tag (car item))
                 (or (eq tag 'item) ; list items interleave with plain-list
                     (eq tag 'plain-list)))
       (when (eq tag 'item)
-        (incf depth))
+ (setq list-type (org-element-property :type (org-export-get-parent item)))
+ (setq bullet (concat (if (eq list-type 'ordered) "#" "-") bullet)))
       (setq item (org-export-get-parent item)))
-    depth))
+    bullet))

 ;; main interactive entrypoint
 (defun org-confluence-export-as-confluence
-- 
2.5.4 (Apple Git-61)

                 reply	other threads:[~2016-12-05 23:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAM4wePiAufQeEtBwmC24AouyJtqAiDMc0C-D8sKTengi1k-O8g@mail.gmail.com \
    --to=cwdurst+orgmode@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).