(www-format-value-default): New function.
authorMORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
Sun, 28 Mar 2010 20:19:04 +0000 (05:19 +0900)
committerMORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
Sun, 28 Mar 2010 20:19:04 +0000 (05:19 +0900)
(www-format-encode-string):
- Prefer `=gt' to `=cns11643-{1..7}'.
- Display &(G-)GT-Kddddd; entity references.
(www-format-apply-value):
- New implementation for format `string'.
- Use `www-format-value-default' for default format.

cwiki-common.el

index 4a30be9..d8b628a 100644 (file)
          (- (lsh value -8) 32)
          (- (logand value 255) 32)))
 
+(defun www-format-value-default (value &optional without-tags)
+  (if (listp value)
+      (mapconcat
+       (lambda (unit)
+        (www-format-encode-string
+         (format "%S" unit)
+         without-tags))
+       value " ")
+    (www-format-encode-string (format "%S" value) without-tags)))
+  
 (defun www-format-value-as-char-list (value &optional without-tags)
   (if (listp value)
       (mapconcat
          (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
        (let ((coded-charset-entity-reference-alist
               (list*
+               '(=gt                   "GT-" 5 d)
                '(=cns11643-1           "C1-" 4 X)
                '(=cns11643-2           "C2-" 4 X)
                '(=cns11643-3           "C3-" 4 X)
                '(=jis-x0208@1997       "J97-" 4 X)
                '(=jis-x0208@1978       "J78-" 4 X)
                '(=jis-x0208@1983       "J83-" 4 X)
-               '(=gt                   "GT-" 5 d)
                '(=zinbun-oracle        "ZOB-" 4 d)
                '(=jef-china3           "JC3-" 4 X)
                '(=daikanwa             "M-" 5 d)
             t 'literal))
 
          (goto-char (point-min))
+         (while (re-search-forward "&\\(G-\\)?GT-K\\([0-9]+\\);" nil t)
+           (setq code (string-to-int (match-string 2)))
+           (replace-match
+            (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\">"
+                    code
+                    chise-wiki-glyph-cgi-url
+                    code)
+            t 'literal))
+
+         (goto-char (point-min))
          (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
            (setq code (string-to-int (match-string 1) 16))
            (replace-match
            (www-format-value-as-char-list value without-tags))
           ((eq format 'space-separated-ids)
            (www-format-value-as-ids value without-tags))
+          ((eq format 'string)
+           (www-format-encode-string (format "%s" value) without-tags)
+           )
           (t
-            ;; (setq format 'default)
-           (www-format-encode-string
-            (format (www-format-props-to-string props 'default)
-                    value)
-            without-tags))))
+           (www-format-value-default value without-tags)
+            ))
+         )
     (if (or without-tags (eq (plist-get props :mode) 'peek))
        ret
       (format "%s <a href=\"%s?char=%s&feature=%s&format=%s\"