(est-coded-charset-priority-list): Add settings for `=+>ucs@iso',
[chise/est.git] / est-xml.el
1 ;; -*- coding: utf-8-mcs-er -*-
2 (require 'cwiki-common)
3
4
5 ;;; @ XML generator
6 ;;;
7
8 (defun www-xml-format-props (props)
9   (let ((dest "")
10         key val)
11     (while props
12       (setq key (pop props)
13             val (pop props))
14       (if (symbolp key)
15           (setq key (symbol-name key)))
16       (if (eq (aref key 0) ?:)
17           (setq key (substring key 1)))
18       (setq dest
19             (format "%s %s=\"%s\""
20                     dest key
21                     (www-format-encode-string
22                      (format "%s" val) 'without-tags))))
23     dest))
24
25 (defun www-xml-format-unit (format-unit)
26   (let (name props children ret)
27     (cond
28      ((stringp format-unit)
29       (mapconcat (lambda (c)
30                    (cond
31                     ((eq c ?&) "&")
32                     ;; ((eq c ?<) "&amp;lt;")
33                     ;; ((eq c ?>) "&amp;gt;")
34                     (t
35                      (char-to-string c))))
36                  (www-format-encode-string format-unit 'without-tags)
37                  "")
38       )
39      ((consp format-unit)
40       (setq name (car format-unit)
41             props (nth 1 format-unit)
42             children (nthcdr 2 format-unit))
43       (when (eq name 'link)
44         (setq ret (plist-get props :ref))
45         (unless (stringp ret)
46           (setq props (plist-remprop (copy-list props) :ref))
47           (setq children
48                 (cons (list* 'ref nil ret)
49                       children))))
50       (if children
51           (format "<%s%s>%s</%s>"
52                   name
53                   (if props
54                       (www-xml-format-props props)
55                     "")
56                   (www-xml-format-list children)
57                   name)
58         (format "<%s%s/>"
59                 name (www-xml-format-props props)))
60       )
61      (t
62       (format "%s" format-unit)))))
63
64 (defun www-xml-format-list (format-list)
65   (if (atom format-list)
66       (www-xml-format-unit format-list)
67     (mapconcat #'www-xml-format-unit
68                format-list "")))
69
70
71 ;;; @ End.
72 ;;;
73
74 (provide 'est-xml)
75
76 ;;; est-xml.el ends here