(www-feature-value-format): Return 'space-separated-ids for
authorMORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
Tue, 16 Mar 2010 11:49:58 +0000 (20:49 +0900)
committerMORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
Tue, 16 Mar 2010 11:49:58 +0000 (20:49 +0900)
`structure' type features.
(www-format-value-as-ids): New function.
(www-format-apply-value): Use `www-format-value-as-ids' for format
`space-separated-ids'.

cwiki-common.el

index 7089c36..6569ac4 100644 (file)
 
 (defun www-feature-value-format (feature-name)
   (or (char-feature-property feature-name 'value-format)
-      (if (memq (www-feature-type feature-name)
-               '(relation structure))
-         'space-separated-char-list)
+      (let ((type (www-feature-type feature-name)))
+       (cond ((eq type 'relation)
+              'space-separated-char-list)
+             ((eq type 'structure)
+              'space-separated-ids)))
       (if (find-charset feature-name)
          (if (and (= (charset-dimension feature-name) 2)
                   (= (charset-chars feature-name) 94))
        value " ")
     (www-format-encode-string (format "%s" value) without-tags)))
 
+(defun www-format-value-as-ids (value &optional without-tags)
+  (if (listp value)
+      (mapconcat
+       (if without-tags
+          (lambda (unit)
+            (www-format-encode-string
+             (format (if (characterp unit)
+                         "%c"
+                       "%s")
+                     unit)
+             'without-tags))
+        (lambda (unit)
+          (if (characterp unit)
+              (format "<a href=\"%s?char=%s\">%s</a>"
+                      chise-wiki-view-url
+                      (www-uri-encode-char unit)
+                      (www-format-encode-string (char-to-string unit)))
+            (www-format-encode-string (format "%s" unit)))))
+       (ideographic-structure-to-ids value) " ")
+    (www-format-encode-string (format "%s" value) without-tags)))
+
 (defun www-format-value-as-S-exp (value &optional without-tags)
   (www-format-encode-string (format "%S" value) without-tags))
 
            (www-format-value-as-kuten value))
           ((eq format 'space-separated-char-list)
            (www-format-value-as-char-list value without-tags))
+          ((eq format 'space-separated-ids)
+           (www-format-value-as-ids value without-tags))
           (t
            (setq format 'default)
            (www-format-encode-string