1 ;; -*- coding: utf-8-mcs-er -*-
2 (require 'cwiki-common)
8 (defun est-format-props (props)
15 (setq key (symbol-name key)))
16 (if (eq (aref key 0) ?:)
17 (setq key (substring key 1)))
19 (format "%s %s=\"%s\""
21 (www-format-encode-string
23 (est-format-unit val 'without-tags
24 'without-edit 'as-property))
28 (defun est-format-unit (format-unit
29 &optional output-format without-edit as-property
32 ((or (eq output-format 'without-tags)
34 (setq output-format 'plain-text)
36 ((eq output-format 'wiki-text)
38 ((eq output-format 'xml)
41 (setq output-format 'html)
43 (let (name props children ret object feature format value
44 output-string subtype)
46 ((stringp format-unit)
47 (www-format-encode-string format-unit
48 (not (eq output-format 'html))
51 ((characterp format-unit)
52 (www-format-encode-string (format "%S" format-unit)
53 (not (eq output-format 'html))
56 ((symbolp format-unit)
57 (www-format-encode-string (format "%s" format-unit)
58 (not (eq output-format 'html))
62 (setq name (car format-unit)
63 props (nth 1 format-unit)
64 children (nthcdr 2 format-unit))
68 ((or (eq output-format 'plain-text)
69 (eq output-format 'wiki-text))
71 (setq separator (plist-get props :separator)))
72 (setq subtype (plist-get props :subtype))
74 (est-format-list children output-format
75 without-edit as-property separator subtype))
77 ((eq output-format 'html)
78 (setq props (list* :class name props)
84 ((eq output-format 'html)
86 (when (setq object (plist-get props :object))
90 (list :href (www-uri-make-object-url object))
93 ((eq output-format 'wiki-text)
94 (when (setq object (plist-get props :object))
97 (est-object-genre object)
98 (est-format-object object))))
101 ((eq name 'prev-char)
103 ((eq output-format 'wiki-text)
104 (setq output-string "{{prev-char}}")
106 ((and (eq output-format 'html)
107 (setq object (plist-get props :object))
108 (setq feature (plist-get props :feature))
109 (setq value (www-get-feature-value object feature))
110 (setq ret (find-previous-defined-code-point feature value)))
114 (list :href (www-uri-make-object-url ret))
118 ((eq name 'next-char)
120 ((eq output-format 'wiki-text)
121 (setq output-string "{{next-char}}")
123 ((and (eq output-format 'html)
124 (setq object (plist-get props :object))
125 (setq feature (plist-get props :feature))
126 (setq value (www-get-feature-value object feature))
127 (setq ret (find-next-defined-code-point feature value)))
131 (list :href (www-uri-make-object-url ret))
137 ((eq output-format 'wiki-text)
138 (setq output-string "{{...}}")
140 ((and (eq output-format 'html)
141 (setq object (plist-get props :object))
142 (setq feature (plist-get props :feature)))
147 (concat (www-uri-make-object-url object)
148 (if est-hide-cgi-mode
151 (www-uri-encode-feature-name feature)))
155 ((eq name 'feature-name)
157 (when (eq output-format 'html)
158 (when (and (setq object (plist-get props :object))
159 (setq feature (plist-get props :feature)))
164 (www-uri-make-feature-name-url
165 (est-object-genre object)
166 (www-uri-encode-feature-name feature)
167 (www-uri-encode-object object)))
172 ((eq output-format 'wiki-text)
174 (if (and (setq object (plist-get props :object))
175 (setq feature (plist-get props :feature)))
176 (format "{{value %s %s=%s}}"
178 (est-object-genre object)
179 (www-uri-encode-object object))
182 ((eq output-format 'html)
184 (if (consp (car children))
189 (list (list 'edit-value
191 (list* :format format props)
194 (:type "submit" :value "edit")))))))
196 props (list* :class "value" props))
199 ((or (and (eq name 'link)
200 (setq ret (plist-get props :ref)))
202 (setq ret (plist-get props :href))))
204 ((eq output-format 'wiki-text)
207 (est-format-list children output-format)
208 (est-format-unit ret output-format)
211 ((eq output-format 'html)
213 props (list* :href ret
214 (plist-remprop (copy-list props) :ref)))
216 ((eq output-format 'xml)
217 (unless (stringp ret)
218 (setq props (plist-remprop (copy-list props) :ref))
220 (cons (list 'ref nil ret)
224 ((and (eq name 'edit-value)
225 (setq object (plist-get props :object))
226 (setq feature (plist-get props :feature)))
227 (setq format (or (plist-get props :format) 'default))
229 props (list :href (format "%s?%s=%s&feature=%s&format=%s"
231 (est-object-genre object)
232 (www-uri-encode-object object)
233 (www-uri-encode-feature-name feature)
242 (when (eq output-format 'html)
243 (setq props (list* :class name props)
250 (setq separator (plist-get props :separator)))
251 (setq subtype (plist-get props :subtype))
254 ((eq output-format 'plain-text)
255 (est-format-list children output-format as-property separator
258 ((eq subtype 'unordered-list)
259 (format "<ul\n%s><li\n>%s</li></ul\n>"
261 (est-format-props props)
264 children output-format
265 without-edit as-property "</li\n><li\n>")
270 (format "<%s%s>%s</%s>"
273 (est-format-props props)
276 children output-format
277 without-edit as-property separator)
280 (if (eq output-format 'plain-text)
283 name (est-format-props props))))
287 (format "%s" format-unit)))))
289 (defun est-format-list (format-list
290 &optional output-format without-edit as-property
295 format-list output-format without-edit as-property separator)
297 ((eq subtype 'unordered-list)
299 (mapconcat (lambda (unit)
301 unit output-format without-edit as-property separator))
302 format-list "</li\n><li>")
306 (mapconcat (lambda (unit)
308 unit output-format without-edit as-property))
309 format-list separator)
316 (provide 'est-format)
318 ;;; est-format.el ends here