1 ;; -*- coding: utf-8-mcs-er -*-
2 (require 'char-db-util)
4 (setq file-name-coding-system 'utf-8-mcs-er)
7 (concord-assign-genre 'creator@ruimoku "/usr/local/var/ruimoku/db")
8 (concord-assign-genre 'person-name@ruimoku "/usr/local/var/ruimoku/db")
10 (concord-assign-genre 'journal-volume@ruimoku "/usr/local/var/ruimoku/db")
11 (concord-assign-genre 'article@ruimoku "/usr/local/var/ruimoku/db")
12 (concord-assign-genre 'book@ruimoku "/usr/local/var/ruimoku/db")
14 (concord-assign-genre 'classification@ruimoku "/usr/local/var/ruimoku/db")
15 (concord-assign-genre 'region@ruimoku "/usr/local/var/ruimoku/db")
16 (concord-assign-genre 'era@ruimoku "/usr/local/var/ruimoku/db")
17 (concord-assign-genre 'period@ruimoku "/usr/local/var/ruimoku/db")
18 (concord-assign-genre 'journal@ruimoku "/usr/local/var/ruimoku/db")
19 (concord-assign-genre 'journal-name@ruimoku "/usr/local/var/ruimoku/db")
20 (concord-assign-genre 'publisher@ruimoku "/usr/local/var/ruimoku/db")
21 (concord-assign-genre 'publisher-name@ruimoku "/usr/local/var/ruimoku/db")
23 (mount-char-attribute-table '*instance@ruimoku/bibliography/title)
24 ;; (mount-char-attribute-table '*instance@ruimoku/bibliography/content*note)
26 (concord-assign-genre 'entry@zh-classical "/usr/local/var/kanbun/db")
27 ;; (concord-assign-genre 'morpheme-entry@zh-classical "/usr/local/var/kanbun/db")
28 (concord-assign-genre 'word-class@zh-classical "/usr/local/var/kanbun/db")
29 (concord-assign-genre 'morpheme@zh-classical "/usr/local/var/kanbun/db")
30 (concord-assign-genre 'sentence@zh-classical "/usr/local/var/kanbun/db")
31 ;; (concord-assign-genre 'sentence-entry@zh-classical "/usr/local/var/kanbun/db")
33 (mount-char-attribute-table '*instance@morpheme-entry/zh-classical)
36 (defvar chise-wiki-view-url "view.cgi")
37 (defvar chise-wiki-edit-url "edit.cgi")
39 (defvar chise-wiki-bitmap-glyphs-url
40 "http://www.chise.org/glyphs")
42 (defvar chise-wiki-glyph-cgi-url
43 "http://www.chise.org/chisewiki/glyph.cgi")
45 (defvar chise-wiki-displayed-features nil)
47 (defun decode-uri-string (string &optional coding-system)
48 (if (> (length string) 0)
52 (mapconcat (lambda (char)
55 (char-to-string char)))
57 (while (string-match "%\\([0-9A-F][0-9A-F]\\)" string i)
58 (setq dest (concat dest
59 (substring string i (match-beginning 0))
62 (string-to-int (match-string 1 string) 16))))
65 (concat dest (substring string i))
68 (defun www-feature-type (feature-name)
69 (or (char-feature-property feature-name 'type)
70 (let ((str (symbol-name feature-name)))
72 ((string-match "\\*note\\(@[^*]+\\)?$" str)
74 ((string-match "\\*sources\\(@[^*]+\\)?$" str)
76 ((string-match "\\*" str)
78 ((string-match "^\\(->\\|<-\\)" str)
80 ((string-match "^ideographic-structure\\(@\\|$\\)" str)
84 (defun www-feature-format (feature-name)
85 (or (char-feature-property feature-name 'format)
87 (setq fn feature-name)
88 (while (and (setq parent (char-feature-name-parent fn))
90 (char-feature-property
94 '((name) " : " (value))))
96 (defun www-feature-value-format (feature-name)
97 (or (char-feature-property feature-name 'value-presentation-format)
98 (char-feature-property feature-name 'value-format)
100 (setq fn feature-name)
101 (while (and (setq parent (char-feature-name-parent fn))
103 (or (char-feature-property
104 parent 'value-presentation-format)
105 (char-feature-property
106 parent 'value-format)))))
109 (let ((type (www-feature-type feature-name)))
110 (cond ((eq type 'relation)
112 ((eq type 'structure)
113 'space-separated-ids)
117 (if (find-charset feature-name)
118 (if (and (= (charset-dimension feature-name) 2)
119 (= (charset-chars feature-name) 94))
121 " (" (decimal) ") <" (ku-ten) "> " (prev-char) (next-char))
122 '("0x" (HEX) " (" (decimal) ") " (prev-char) (next-char))))
125 (defun char-feature-name-at-domain (feature-name domain)
127 (let ((name (symbol-name feature-name)))
129 ((string-match "@[^*]+$" name)
130 (intern (format "%s/%s" name domain))
133 (intern (format "%s@%s" name domain))
137 (defun char-feature-name-parent (feature-name)
138 (let ((name (symbol-name feature-name)))
139 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
140 (intern (substring name 0 (car (last (match-data) 2)))))))
142 (defun char-feature-name-domain (feature-name)
143 (let ((name (symbol-name feature-name)))
144 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
145 (intern (substring name (1+ (match-beginning 0)))))))
147 (defun char-feature-name-sans-versions (feature)
148 (let ((feature-name (symbol-name feature)))
149 (if (string-match "[@/]\\$rev=latest$" feature-name)
150 (intern (substring feature-name 0 (match-beginning 0)))
153 (defun est-object-genre (object)
154 (if (characterp object)
156 (concord-object-genre object)))
158 (defun www-get-feature-value (object feature)
159 (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest)))
162 (mount-char-attribute-table latest-feature)
163 (or (char-feature object latest-feature)
164 (char-feature object feature))
167 (or (condition-case nil
168 (concord-object-get object latest-feature)
171 (concord-object-get object feature)
175 (defun get-previous-code-point (ccs code)
176 (let ((chars (charset-chars ccs))
177 (dim (charset-dimension ccs))
179 mask byte-min byte-max
202 (setq bytes (make-vector dim 0))
204 (aset bytes i (logand (lsh code (* i -8)) mask))
207 (while (and (< i dim)
209 (aset bytes i (1- (aref bytes i)))
210 (< (aref bytes i) byte-min)))
211 (aset bytes i byte-max)
214 (setq dest (aref bytes 0)
217 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
221 (defun get-next-code-point (ccs code)
222 (let ((chars (charset-chars ccs))
223 (dim (charset-dimension ccs))
225 mask byte-min byte-max
248 (setq bytes (make-vector dim 0))
250 (aset bytes i (logand (lsh code (* i -8)) mask))
253 (while (and (< i dim)
255 (aset bytes i (1+ (aref bytes i)))
256 (> (aref bytes i) byte-max)))
257 (aset bytes i byte-min)
260 (setq dest (aref bytes 0)
263 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
267 (defun find-previous-defined-code-point (ccs code)
268 (let ((i (get-previous-code-point ccs code))
271 ((eq ccs '=jis-x0208)
272 (setq ccs '=jis-x0208@1990))
273 ((eq ccs '=jis-x0213-1)
274 (setq ccs '=jis-x0213-1@2004)))
277 (null (setq char (decode-char ccs i
278 (unless (eq ccs '=ucs)
280 (setq i (get-previous-code-point ccs i)))
283 (defun find-next-defined-code-point (ccs code)
284 (let ((i (get-next-code-point ccs code))
286 (setq max (+ code 1000))
288 ((eq ccs '=jis-x0208)
289 (setq ccs '=jis-x0208@1990))
290 ((eq ccs '=jis-x0213-1)
291 (setq ccs '=jis-x0213-1@2004)))
294 (null (setq char (decode-char ccs i
295 (unless (eq ccs '=ucs)
297 (setq i (get-next-code-point ccs i)))
301 ;;; @ URI representation
304 (defun www-uri-decode-feature-name (uri-feature)
306 (setq uri-feature (decode-uri-string uri-feature 'utf-8-mcs-er))
308 ((string-match "^from\\." uri-feature)
309 (intern (format "<-%s" (substring uri-feature (match-end 0))))
311 ((string-match "^to\\." uri-feature)
312 (intern (format "->%s" (substring uri-feature (match-end 0))))
314 ((string-match "^rep\\." uri-feature)
315 (intern (format "=%s" (substring uri-feature (match-end 0))))
317 ((string-match "^rep2\\." uri-feature)
318 (intern (format "==%s" (substring uri-feature (match-end 0))))
320 ((string-match "^g\\." uri-feature)
321 (intern (format "=>>%s" (substring uri-feature (match-end 0))))
323 ((string-match "^gi\\." uri-feature)
324 (intern (format "=>>>%s" (substring uri-feature (match-end 0))))
326 ((string-match "^gi\\([0-9]+\\)\\." uri-feature)
327 (intern (format "=>>%s%s"
328 (make-string (string-to-int
329 (match-string 1 uri-feature))
331 (substring uri-feature (match-end 0))))
333 ((string-match "^o\\." uri-feature)
334 (intern (format "=+>%s" (substring uri-feature (match-end 0))))
336 ((string-match "^a\\." uri-feature)
337 (intern (format "=>%s" (substring uri-feature (match-end 0))))
339 ((string-match "^a\\([0-9]+\\)\\." uri-feature)
340 (intern (format "%s>%s"
341 (make-string (string-to-int
342 (match-string 1 uri-feature))
344 (substring uri-feature (match-end 0))))
346 ((and (setq feature (intern (format "=>%s" uri-feature)))
347 (find-charset feature))
349 ((and (setq feature (intern (format "=>>%s" uri-feature)))
350 (find-charset feature))
352 ((and (setq feature (intern (format "=>>>%s" uri-feature)))
353 (find-charset feature))
355 ((and (setq feature (intern (format "=%s" uri-feature)))
356 (find-charset feature))
358 (t (intern uri-feature)))))
360 (defun www-uri-encode-feature-name (feature-name)
361 (setq feature-name (symbol-name feature-name))
363 ((string-match "^=\\+>\\([^=>]+\\)" feature-name)
364 (concat "o." (substring feature-name (match-beginning 1)))
366 ((string-match "^=\\([^=>]+\\)" feature-name)
367 (concat "rep." (substring feature-name (match-beginning 1)))
369 ((string-match "^==\\([^=>]+\\)" feature-name)
370 (concat "rep2." (substring feature-name (match-beginning 1)))
372 ((string-match "^=>>\\([^=>]+\\)" feature-name)
373 (concat "g." (substring feature-name (match-beginning 1)))
375 ((string-match "^=>>>\\([^=>]+\\)" feature-name)
376 (concat "gi." (substring feature-name (match-beginning 1)))
378 ((string-match "^=>>\\(>+\\)" feature-name)
380 (length (match-string 1 feature-name))
381 (substring feature-name (match-end 1)))
383 ((string-match "^=>\\([^=>]+\\)" feature-name)
384 (concat "a." (substring feature-name (match-beginning 1)))
386 ((string-match "^\\(=+\\)>" feature-name)
388 (length (match-string 1 feature-name))
389 (substring feature-name (match-end 0)))
391 ((string-match "^->" feature-name)
392 (concat "to." (substring feature-name (match-end 0)))
394 ((string-match "^<-" feature-name)
395 (concat "from." (substring feature-name (match-end 0)))
399 (defun www-uri-make-feature-name-url (uri-genre uri-feature-name uri-object)
400 (format "%s?feature=%s&%s=%s"
401 chise-wiki-view-url uri-feature-name uri-genre uri-object))
403 (defun www-uri-decode-object (genre char-rep)
406 ((string-match "\\(%3A\\|:\\)" char-rep)
407 (setq ccs (substring char-rep 0 (match-beginning 0))
408 cpos (substring char-rep (match-end 0)))
409 (setq ccs (www-uri-decode-feature-name ccs))
411 ((string-match "^0x" cpos)
413 (string-to-number (substring cpos (match-end 0)) 16))
416 (setq cpos (car (read-from-string
418 cpos file-name-coding-system))))
420 (if (and (eq genre 'character)
422 (decode-char ccs cpos)
423 (concord-decode-object ccs cpos genre))
426 (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
428 ((eq genre 'character)
429 (when (= (length char-rep) 1)
433 (concord-decode-object
434 '=id (www-uri-decode-feature-name char-rep) 'feature)
437 (concord-decode-object
438 '=id (car (read-from-string char-rep)) genre)
441 (defun www-uri-encode-object (object)
442 (if (characterp object)
443 (if (encode-char object '=ucs)
446 (format "%%%02X" byte))
447 (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
449 (let ((ccs-list '(; =ucs
450 =cns11643-1 =cns11643-2 =cns11643-3
451 =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
453 =jis-x0208 =jis-x0208@1990
458 =jis-x0213-1@2000 =jis-x0213-1@2004
459 =jis-x0208@1983 =jis-x0208@1978
460 =zinbun-oracle =>zinbun-oracle
464 =>>>jis-x0208 =>>>jis-x0213-1 =>>>jis-x0213-2
465 =>>jis-x0208 =>>jis-x0213-1 =>>jis-x0213-2
467 =+>jis-x0208 =+>jis-x0213-1 =+>jis-x0213-2
470 =>jis-x0208 =>jis-x0213-1
472 =>ucs@iso =>ucs@unicode
473 =>ucs@jis =>ucs@cns =>ucs@ks
474 =>>ucs@iso =>>ucs@unicode
475 =>>ucs@jis =>>ucs@cns =>>ucs@ks
476 =>>>ucs@iso =>>>ucs@unicode
477 =>>>ucs@jis =>>>ucs@cns =>>>ucs@ks
483 (setq ccs (pop ccs-list))
484 (not (setq ret (encode-char object ccs 'defined-only)))))
487 (www-uri-encode-feature-name ccs)
489 ((and (setq ccs (car (split-char object)))
490 (setq ret (encode-char object ccs)))
492 (www-uri-encode-feature-name ccs)
495 (format "system-char-id:0x%X"
496 (encode-char object 'system-char-id))
498 (format "rep.id:%s" (concord-object-id object))))
500 (defun est-format-object (object &optional readable)
501 (if (characterp object)
502 (char-to-string object)
503 (let ((ret (or (if readable
504 (or (concord-object-get object 'name)
505 (concord-object-get object '=name)
506 (concord-object-get object 'title)))
507 (concord-object-id object))))
510 (defun www-uri-make-object-url (object &optional uri-object)
513 (est-object-genre object)
515 (www-uri-encode-object object))))
518 ;;; @ Feature name presentation
521 (defun www-format-feature-name-default (feature-name)
525 (symbol-name feature-name)
529 (defun www-format-feature-name-as-metadata (feature-name &optional lang)
530 (let ((str (symbol-name feature-name))
533 ((string-match "\\*[^*]+$" str)
534 (setq base (substring str 0 (match-beginning 0))
535 meta (substring str (match-beginning 0)))
536 (concat (www-format-feature-name* (intern base) lang)
539 (www-format-feature-name-default feature-name)
542 (defun www-format-feature-name-as-rel-to (feature-name)
543 (concat "\u2192" (substring (symbol-name feature-name) 2)))
545 (defun www-format-feature-name-as-rel-from (feature-name)
546 (concat "\u2190" (substring (symbol-name feature-name) 2)))
548 (defun www-format-feature-name-as-CCS (feature-name)
551 (symbol-name feature-name)
553 (dest (upcase (pop rest))))
554 (when (string-match "^=+>*" dest)
555 (setq dest (concat (substring dest 0 (match-end 0))
557 (substring dest (match-end 0)))))
561 (setq dest (concat dest " " (upcase (pop rest)))))
562 (if (string-match "^[0-9]+$" (car rest))
563 (concat dest "-" (car rest))
564 (concat dest " " (upcase (car rest))))
568 (defun www-format-feature-name* (feature-name &optional lang)
569 (let (name fn parent ret)
572 (char-feature-property
574 (intern (format "name@%s" lang))))
575 (char-feature-property
576 feature-name 'name)))
577 ((and (setq name (symbol-name feature-name))
578 (string-match "\\*" name))
579 (www-format-feature-name-as-metadata feature-name lang))
581 (setq fn feature-name)
582 (while (and (setq parent (char-feature-name-parent fn))
585 (char-feature-property
587 (intern (format "name@%s" lang))))
588 (char-feature-property
593 (concat ret (substring (symbol-name feature-name)
594 (length (symbol-name parent)))))
595 ((find-charset feature-name)
596 (www-format-feature-name-as-CCS feature-name))
597 ((string-match "^\\(->\\)" name)
598 (www-format-feature-name-as-rel-to feature-name))
599 ((string-match "^\\(<-\\)" name)
600 (www-format-feature-name-as-rel-from feature-name))
602 (www-format-feature-name-default feature-name)
606 (defun www-format-feature-name (feature-name &optional lang)
607 (www-format-encode-string
608 (www-format-feature-name* feature-name lang)))
614 (defvar www-format-char-img-style "vertical-align:bottom;")
616 (defun www-format-encode-string (string &optional without-tags as-body)
619 (let (plane code start end char variants ret rret)
621 (goto-char (point-min))
622 (while (search-forward "&" nil t)
623 (replace-match "&" nil t)))
624 (goto-char (point-min))
625 (while (search-forward "<" nil t)
626 (replace-match "<" nil t))
627 (goto-char (point-min))
628 (while (search-forward ">" nil t)
629 (replace-match ">" nil t))
631 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
632 (let ((coded-charset-entity-reference-alist
635 '(=hanyo-denshi/ja "HD-JA-" 4 X)
636 '(=hanyo-denshi/jb "HD-JB-" 4 X)
637 '(=hanyo-denshi/jc "HD-JC-" 4 X)
638 '(=hanyo-denshi/jd "HD-JD-" 4 X)
639 '(=hanyo-denshi/ft "HD-FT-" 4 X)
640 '(=hanyo-denshi/ia "HD-IA-" 4 X)
641 '(=hanyo-denshi/ib "HD-IB-" 4 X)
642 '(=hanyo-denshi/hg "HD-HG-" 4 X)
643 '(=hanyo-denshi/ip "HD-IP-" 4 X)
644 '(=hanyo-denshi/jt "HD-JT-" 4 X)
645 '(=hanyo-denshi/ks "HD-KS-" 6 d)
646 '(=cns11643-1 "C1-" 4 X)
647 '(=cns11643-2 "C2-" 4 X)
648 '(=cns11643-3 "C3-" 4 X)
649 '(=cns11643-4 "C4-" 4 X)
650 '(=cns11643-5 "C5-" 4 X)
651 '(=cns11643-6 "C6-" 4 X)
652 '(=cns11643-7 "C7-" 4 X)
653 '(=adobe-japan1-6 "AJ1-" 5 d)
654 '(=big5-cdp "CDP-" 4 X)
656 '(=gb12345 "G1-" 4 X)
657 '(=jis-x0208@1990 "J90-" 4 X)
658 '(=jis-x0212 "JSP-" 4 X)
660 '(=jis-x0208@1997 "J97-" 4 X)
661 '(=jis-x0208@1978 "J78-" 4 X)
662 '(=jis-x0208@1983 "J83-" 4 X)
663 '(=ruimoku-v6 "RUI6-" 4 X)
664 '(=zinbun-oracle "ZOB-" 4 d)
665 '(=jef-china3 "JC3-" 4 X)
666 '(=ucs@unicode "UU+" 4 X)
667 '(=ucs@JP/hanazono "hanaJU+" 4 X)
668 '(=daikanwa "M-" 5 d)
669 '(==cns11643-1 "R-C1-" 4 X)
670 '(==cns11643-2 "R-C2-" 4 X)
671 '(==cns11643-3 "R-C3-" 4 X)
672 '(==cns11643-4 "R-C4-" 4 X)
673 '(==cns11643-5 "R-C5-" 4 X)
674 '(==cns11643-6 "R-C6-" 4 X)
675 '(==cns11643-7 "R-C7-" 4 X)
676 coded-charset-entity-reference-alist)))
677 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
679 (goto-char (point-min))
680 (while (re-search-forward "&CB\\([0-9]+\\);" nil t)
681 (setq code (string-to-int (match-string 1)))
683 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
686 chise-wiki-bitmap-glyphs-url
688 www-format-char-img-style)
691 (goto-char (point-min))
692 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?J\\(78\\|83\\|90\\|97\\|SP\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
693 (setq plane (match-string 2)
694 code (string-to-int (match-string 3) 16))
696 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
699 chise-wiki-bitmap-glyphs-url
702 (- (logand code 255) 32)
703 www-format-char-img-style)
706 (goto-char (point-min))
707 (while (re-search-forward "&\\(o-\\)?HD-\\(JA\\|JB\\|JC\\|JD\\|FT\\|IA\\|IB\\|HG\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
708 (setq plane (match-string 2)
709 code (string-to-int (match-string 3) 16))
711 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%02d%02d.png\"
714 chise-wiki-bitmap-glyphs-url
717 (- (logand code 255) 32)
718 www-format-char-img-style)
721 (goto-char (point-min))
722 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?HD-\\(IP\\|JT\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
723 (setq plane (match-string 2)
724 code (string-to-int (match-string 3) 16))
726 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%04X.png\"
729 chise-wiki-bitmap-glyphs-url
731 www-format-char-img-style)
734 (goto-char (point-min))
735 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?HD-KS-\\([0-9]+\\);" nil t)
736 (setq code (string-to-int (match-string 2)))
738 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
739 style=\"vertical-align:middle\">"
741 chise-wiki-bitmap-glyphs-url
743 www-format-char-img-style)
746 (goto-char (point-min))
747 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
748 (setq plane (string-to-int (match-string 1))
749 code (string-to-int (match-string 2) 16))
751 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
754 chise-wiki-bitmap-glyphs-url
757 (- (logand code 255) 32)
758 www-format-char-img-style)
761 (goto-char (point-min))
762 (while (re-search-forward "&\\(R-\\)?C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
763 (setq plane (string-to-int (match-string 2))
764 code (string-to-int (match-string 3) 16))
766 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
769 chise-wiki-bitmap-glyphs-url
771 www-format-char-img-style)
774 (goto-char (point-min))
775 (while (re-search-forward "&JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
776 (setq code (string-to-int (match-string 1) 16))
778 (format "<img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">"
782 (goto-char (point-min))
783 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
784 (setq code (string-to-int (match-string 2)))
786 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
787 style=\"vertical-align:middle\">"
789 chise-wiki-bitmap-glyphs-url
791 www-format-char-img-style)
794 (goto-char (point-min))
795 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?AJ1-\\([0-9]+\\);" nil t)
796 (setq code (string-to-int (match-string 2)))
798 (format "<img alt=\"AJ1-%05d\" src=\"%s/IVD/AdobeJapan1/CID+%d.png\"
799 style=\"vertical-align:middle\">"
801 chise-wiki-bitmap-glyphs-url
803 www-format-char-img-style)
806 (goto-char (point-min))
807 (while (re-search-forward "&\\(G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
808 (setq code (string-to-int (match-string 2)))
810 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
813 chise-wiki-glyph-cgi-url
815 www-format-char-img-style)
818 (goto-char (point-min))
819 (while (re-search-forward "&\\(G-\\)?GT-K\\([0-9]+\\);" nil t)
820 (setq code (string-to-int (match-string 2)))
822 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
825 chise-wiki-glyph-cgi-url
827 www-format-char-img-style)
830 (goto-char (point-min))
831 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
832 (setq code (string-to-int (match-string 1) 16))
834 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
837 chise-wiki-glyph-cgi-url
839 www-format-char-img-style)
842 (goto-char (point-min))
843 (while (re-search-forward "&CDP-\\([0-9A-F]+\\);" nil t)
844 (setq code (string-to-int (match-string 1) 16))
846 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
849 chise-wiki-glyph-cgi-url
851 www-format-char-img-style)
854 (goto-char (point-min))
855 (while (re-search-forward "&RUI6-\\([0-9A-F]+\\);" nil t)
856 (setq code (string-to-int (match-string 1) 16))
858 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
859 style=\"vertical-align:middle\">"
861 chise-wiki-glyph-cgi-url
863 www-format-char-img-style)
866 (goto-char (point-min))
867 (while (re-search-forward "&hanaJU\\+\\([0-9A-F]+\\);" nil t)
868 (setq code (string-to-int (match-string 1) 16))
870 (format "<img alt=\"hanaJU+%04X\" src=\"%s?char=hana-JU+%04X\"
871 style=\"vertical-align:middle\">"
873 chise-wiki-glyph-cgi-url
875 www-format-char-img-style)
878 (goto-char (point-min))
879 (while (re-search-forward "&\\(A-\\|R-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
880 (setq code (string-to-int (match-string 3) 16))
882 (format "<img alt=\"UU+%04X\" src=\"http://www.unicode.org/cgi-bin/refglyph?24-%04X\"
883 style=\"vertical-align:middle\">"
886 www-format-char-img-style)
889 (goto-char (point-min))
890 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
891 (setq code (string-to-int (match-string 1) 16))
892 (setq start (match-beginning 0)
894 (setq char (decode-char 'system-char-id code))
897 (or (www-get-feature-value char '->subsumptive)
898 (www-get-feature-value char '->denotational)))
901 (setq ret (www-format-encode-string
902 (char-to-string (car variants))))
903 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
904 (setq variants (cdr variants)))
906 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
908 (delete-region start end)
911 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
912 (www-get-feature-value char 'ideographic-structure)))
917 (if (characterp (setq rret (find-char ch)))
920 (www-format-encode-string
921 (char-to-string ch) without-tags)
922 (www-format-encode-string
923 (format "%S" ch) without-tags)))
927 (delete-region start end)
931 ;; (goto-char (point-min))
932 ;; (while (search-forward ">-" nil t)
933 ;; (replace-match "&GT-" t 'literal))
936 (defun www-html-display-text (text)
940 (goto-char (point-min))
941 (while (search-forward "<" nil t)
942 (replace-match "<" nil t))
943 (goto-char (point-min))
944 (while (search-forward ">" nil t)
945 (replace-match ">" nil t))
946 (goto-char (point-min))
947 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
949 (format "<a href=\"%s\">%s</a>"
953 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
954 (goto-char (point-min))
955 (while (search-forward ">-" nil t)
956 (replace-match "&GT-" nil t))
959 (defun www-html-display-paragraph (text)
961 (www-html-display-text text)
968 (defvar coded-charset-GlyphWiki-id-alist
970 (=adobe-japan1-0 "aj1-" 5 d nil)
971 (=adobe-japan1-1 "aj1-" 5 d nil)
972 (=adobe-japan1-2 "aj1-" 5 d nil)
973 (=adobe-japan1-3 "aj1-" 5 d nil)
974 (=adobe-japan1-4 "aj1-" 5 d nil)
975 (=adobe-japan1-5 "aj1-" 5 d nil)
976 (=adobe-japan1-6 "aj1-" 5 d nil)
978 (=decomposition@hanyo-denshi)
979 (=hanyo-denshi/ks "koseki-" 6 d nil)
980 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
981 (=ucs@jis "u" 4 x nil)
982 (=ucs@cns "u" 4 x "-t")
983 (=jis-x0212 "jsp-" 4 x nil)
984 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
985 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
986 (=jis-x0213-2 "jx2-" 4 x nil)
988 (=daikanwa "dkw-" 5 d nil)
989 (=gt-k "gt-k" 5 d nil)
990 (=jef-china3 "jc3-" 4 x nil)
992 (=ucs@ks "u" 4 x "-k")
993 (=ks-x1001 "k0-" 4 x nil)
994 (=jis-x0208@1978/1pr "j78-" 4 x nil)
995 (=jis-x0208@1978/-4pr "j78-" 4 x nil)
996 (=jis-x0208@1978 "j78-" 4 x nil)
997 (=>>>jis-x0208@1978 "j78-" 4 x nil)
998 (=>>jis-x0208@1978 "j78-" 4 x nil)
999 (=+>jis-x0208@1978 "j78-" 4 x nil)
1000 (=ucs@JP "u" 4 x nil)
1001 (=ucs@gb "u" 4 x "-g")
1002 (=ucs@iso "u" 4 x "-u")
1003 (=ucs@unicode "u" 4 x "-us")
1004 (=big5-cdp "cdp-" 4 x nil)
1005 (=>>big5-cdp "cdp-" 4 x nil)
1006 (=cns11643-1 "c1-" 4 x nil)
1007 (=cns11643-2 "c2-" 4 x nil)
1008 (=cns11643-3 "c3-" 4 x nil)
1009 (=cns11643-4 "c4-" 4 x nil)
1010 (=cns11643-5 "c5-" 4 x nil)
1011 (=cns11643-6 "c6-" 4 x nil)
1012 (=cns11643-7 "c7-" 4 x nil)
1013 (=jis-x0208 "j90-" 4 x nil)
1014 (=>>>jis-x0208 "j90-" 4 x nil)
1015 (=>>jis-x0208 "j90-" 4 x nil)
1016 (=+>jis-x0208 "j90-" 4 x nil)
1017 (=jis-x0208@1990 "j90-" 4 x nil)
1018 (=>>>jis-x0208@1990 "j90-" 4 x nil)
1019 (=>>jis-x0208@1990 "j90-" 4 x nil)
1020 (=+>jis-x0208@1990 "j90-" 4 x nil)
1021 (=jis-x0208@1983 "j83-" 4 x nil)
1022 (=>>>jis-x0208@1983 "j83-" 4 x nil)
1023 (=>>jis-x0208@1983 "j83-" 4 x nil)
1024 (=+>jis-x0208@1983 "j83-" 4 x nil)
1025 (=cbeta "cb" 5 d nil)
1026 (=>>daikanwa "dkw-" 5 d nil)
1029 (defun char-GlyphWiki-id (char)
1030 (let ((rest coded-charset-GlyphWiki-id-alist)
1033 (setq spec (pop rest))
1034 (null (setq ret (char-feature char (car spec))))))
1038 (mapconcat #'char-GlyphWiki-id ret "-"))
1039 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
1041 ((and (or (encode-char char '=jis-x0208@1990)
1042 (encode-char char '=jis-x0212)
1043 (encode-char char '=jis-x0213-1))
1044 (setq code (encode-char char '=ucs@jis)))
1045 (format "u%04x" code)
1047 ((and (or (encode-char char '=gb2312)
1048 (encode-char char '=gb12345))
1049 (setq code (encode-char char '=ucs@gb)))
1050 (format "u%04x-g" code)
1052 ((and (or (encode-char char '=cns11643-1)
1053 (encode-char char '=cns11643-2)
1054 (encode-char char '=cns11643-3)
1055 (encode-char char '=cns11643-4)
1056 (encode-char char '=cns11643-5)
1057 (encode-char char '=cns11643-6)
1058 (encode-char char '=cns11643-7))
1059 (setq code (encode-char char '=ucs@cns)))
1060 (format "u%04x-t" code)
1062 ((and (encode-char char '=ks-x1001)
1063 (setq code (encode-char char '=ucs@ks)))
1064 (format "u%04x-k" code)
1066 (format (format "%s%%0%d%s%s"
1070 (or (nth 4 spec) ""))
1077 (provide 'cwiki-common)
1079 ;;; cwiki-common.el ends here