Browse Source

ox-confluence: Handle lists

  * contrib/lisp/ox-confluence.el (org-confluence-item,
    org-confluence--li-depth): New functions.

Patch proposed by <tomas@tuxteam.de>.
Sébastien Delafond 11 years ago
parent
commit
3a65174f14
1 changed files with 22 additions and 0 deletions
  1. 22 0
      contrib/lisp/ox-confluence.el

+ 22 - 0
contrib/lisp/ox-confluence.el

@@ -45,6 +45,7 @@
 		     (footnote-reference . org-confluence-empty)
 		     (headline . org-confluence-headline)
 		     (italic . org-confluence-italic)
+                     (item . org-confluence-item)
 		     (link . org-confluence-link)
 		     (property-drawer . org-confluence-property-drawer)
 		     (section . org-confluence-section)
@@ -71,6 +72,11 @@
 (defun org-confluence-italic (italic contents info)
   (format "_%s_" contents))
 
+(defun org-confluence-item (item contents info)
+  (concat (make-string (1+ (org-confluence--li-depth item)) ?\-)
+          " "
+          (org-trim contents)))
+
 (defun org-confluence-fixed-width (fixed-width contents info)
   (format "\{\{%s\}\}" contents))
 
@@ -144,6 +150,22 @@
           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
+  ;;       (it gets recalculated quite a few times while
+  ;;       traversing a list)
+  (let ((depth -1)
+        (tag))
+    (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 item (org-export-get-parent item)))
+    depth))
+
 ;; main interactive entrypoint
 (defun org-confluence-export-as-confluence
   (&optional async subtreep visible-only body-only ext-plist)