(est-format-unit): Support :subtype property of list node; if subtype
authorMORIOKA Tomohiko <tomo.git@chise.org>
Wed, 12 Sep 2012 01:44:25 +0000 (10:44 +0900)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Wed, 12 Sep 2012 01:44:25 +0000 (10:44 +0900)
`unordered-list' is specified, use <ul> tag.
(est-format-list): Likewise.

est-format.el

index 116d412..bd507be 100644 (file)
@@ -41,7 +41,7 @@
     (setq output-format 'html)
     ))
   (let (name props children ret object feature format value
-            output-string)
+            output-string subtype)
     (cond
      ((stringp format-unit)
       (www-format-encode-string format-unit
              (eq output-format 'wiki-text))
          (unless separator
            (setq separator (plist-get props :separator)))
+         (setq subtype (plist-get props :subtype))
          (setq output-string
                (est-format-list children output-format
-                                without-edit as-property separator))
+                                without-edit as-property separator subtype))
          )
         ((eq output-format 'html)
          (setq props (list* :class name props)
        (t
        (unless separator
          (setq separator (plist-get props :separator)))
+       (setq subtype (plist-get props :subtype))
        (if children
-           (if (eq output-format 'plain-text)
-               (est-format-list children output-format as-property separator)
+           (cond
+            ((eq output-format 'plain-text)
+             (est-format-list children output-format as-property separator
+                              subtype)
+             )
+            ((eq subtype 'unordered-list)
+             (format "<ul\n%s><li\n>%s</li></ul\n>"
+                     (if props
+                         (est-format-props props)
+                       "")
+                     (est-format-list
+                      children output-format
+                      without-edit as-property "</li\n><li\n>")
+                     )
+             
+             )
+            (t
              (format "<%s%s>%s</%s>"
                      name
                      (if props
                      (est-format-list
                       children output-format
                       without-edit as-property separator)
-                     name))
+                     name)
+             ))
          (if (eq output-format 'plain-text)
              ""
            (format "<%s%s/>"
 
 (defun est-format-list (format-list
                        &optional output-format without-edit as-property
-                       separator)
-  (if (atom format-list)
-      (est-format-unit
-       format-list output-format without-edit as-property separator)
+                       separator subtype)
+  (cond
+   ((atom format-list)
+    (est-format-unit
+     format-list output-format without-edit as-property separator)
+    )
+   ((eq subtype 'unordered-list)
+    (concat "<ul\n><li>"
+           (mapconcat (lambda (unit)
+                        (est-format-unit
+                         unit output-format without-edit as-property separator))
+                      format-list "</li\n><li>")
+           "</li\n></ul\n>")
+    )
+   (t
     (mapconcat (lambda (unit)
                 (est-format-unit
                  unit output-format without-edit as-property separator))
-              format-list separator)))
+              format-list separator)
+    )))
 
 
 ;;; @ End.