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\""
22 (est-format-unit val 'without-tags
23 'without-edit 'as-property))
27 (defun est-format-unit (format-unit
28 &optional output-format without-edit as-property
31 ((or (eq output-format 'without-tags)
33 (setq output-format 'plain-text)
35 ((eq output-format 'wiki-text)
37 ((eq output-format 'xml)
40 (setq output-format 'html)
42 (let (name props children ret object feature format value
43 output-string subtype)
45 ((stringp format-unit)
46 (www-format-encode-string format-unit
47 (not (eq output-format 'html))
50 ((characterp format-unit)
51 (www-format-encode-string (format "%S" format-unit)
52 (not (eq output-format 'html))
55 ((symbolp format-unit)
56 (www-format-encode-string (format "%s" format-unit)
57 (not (eq output-format 'html))
61 (setq name (car format-unit)
62 props (nth 1 format-unit)
63 children (nthcdr 2 format-unit))
66 (eq name 'image-list))
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)))
163 '(:class "feature-name")
166 (www-uri-make-feature-name-url
167 (est-object-genre object)
168 (www-uri-encode-feature-name feature)
169 (www-uri-encode-object object)))
174 ((eq output-format 'wiki-text)
176 (if (and (setq object (plist-get props :object))
177 (setq feature (plist-get props :feature)))
178 (format "{{value %s %s=%s}}"
180 (est-object-genre object)
181 (www-uri-encode-object object))
184 ((eq output-format 'html)
186 (if (consp (car children))
191 (list (list 'edit-value
193 (list* :format format props)
196 (:type "submit" :value "edit")))))))
198 props (list* :class "value" props))
201 ((or (and (eq name 'link)
202 (setq ret (plist-get props :ref)))
204 (setq ret (plist-get props :href))))
206 ((eq output-format 'wiki-text)
209 (est-format-list children output-format)
210 (est-format-unit ret output-format)
213 ((eq output-format 'html)
215 props (list* :href ret
216 (plist-remprop (copy-list props) :ref)))
218 ((eq output-format 'xml)
219 (unless (stringp ret)
220 (setq props (plist-remprop (copy-list props) :ref))
222 (cons (list 'ref nil ret)
226 ((and (eq name 'edit-value)
227 (setq object (plist-get props :object))
228 (setq feature (plist-get props :feature)))
229 (setq format (or (plist-get props :format) 'default))
231 props (list :href (format "%s?%s=%s&feature=%s&format=%s"
233 (est-object-genre object)
234 (www-uri-encode-object object)
235 (www-uri-encode-feature-name feature)
244 (when (eq output-format 'html)
245 (setq props (list* :class name props)
252 (setq separator (plist-get props :separator)))
253 (setq subtype (plist-get props :subtype))
256 ((eq output-format 'plain-text)
257 (est-format-list children output-format as-property separator
260 ((eq subtype 'unordered-list)
261 (format "<ul\n%s><li\n>%s</li></ul\n>"
263 (est-format-props props)
266 children output-format
267 without-edit as-property "</li\n><li\n>")
272 (format "<%s%s>%s</%s>"
275 (est-format-props props)
278 children output-format
279 without-edit as-property separator)
282 (if (eq output-format 'plain-text)
285 name (est-format-props props))))
289 (format "%s" format-unit)))))
291 (defun est-format-list (format-list
292 &optional output-format without-edit as-property
297 format-list output-format without-edit as-property separator)
299 ((eq subtype 'unordered-list)
301 (mapconcat (lambda (unit)
303 unit output-format without-edit as-property separator))
304 format-list "</li\n><li>")
308 (mapconcat (lambda (unit)
310 unit output-format without-edit as-property))
311 format-list separator)
318 (provide 'est-format)
320 ;;; est-format.el ends here