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 'morpheme-entry@zh-classical "/usr/local/var/kanbun/db")
27 (concord-assign-genre 'word-class@zh-classical "/usr/local/var/kanbun/db")
28 (concord-assign-genre 'morpheme@zh-classical "/usr/local/var/kanbun/db")
29 (concord-assign-genre 'sentence@zh-classical "/usr/local/var/kanbun/db")
30 (concord-assign-genre 'sentence-entry@zh-classical "/usr/local/var/kanbun/db")
32 (mount-char-attribute-table '*instance@morpheme-entry/zh-classical)
35 (defvar chise-wiki-view-url "view.cgi")
36 (defvar chise-wiki-edit-url "edit.cgi")
38 (defvar chise-wiki-bitmap-glyphs-url
39 "http://www.chise.org/glyphs")
41 (defvar chise-wiki-glyph-cgi-url
42 "http://www.chise.org/chisewiki/glyph.cgi")
44 (defvar chise-wiki-displayed-features nil)
46 (defun decode-uri-string (string &optional coding-system)
47 (if (> (length string) 0)
51 (mapconcat (lambda (char)
54 (char-to-string char)))
56 (while (string-match "%\\([0-9A-F][0-9A-F]\\)" string i)
57 (setq dest (concat dest
58 (substring string i (match-beginning 0))
61 (string-to-int (match-string 1 string) 16))))
64 (concat dest (substring string i))
67 (defun www-feature-type (feature-name)
68 (or (char-feature-property feature-name 'type)
69 (let ((str (symbol-name feature-name)))
71 ((string-match "\\*note\\(@[^*]+\\)?$" str)
73 ((string-match "\\*sources\\(@[^*]+\\)?$" str)
75 ((string-match "\\*" str)
77 ((string-match "^\\(->\\|<-\\)" str)
79 ((string-match "^ideographic-structure\\(@\\|$\\)" str)
83 (defun www-feature-format (feature-name)
84 (or (char-feature-property feature-name 'format)
86 (setq fn feature-name)
87 (while (and (setq parent (char-feature-name-parent fn))
89 (char-feature-property
93 '((name) " : " (value))))
95 (defun www-feature-value-format (feature-name)
96 (or (char-feature-property feature-name 'value-presentation-format)
97 (char-feature-property feature-name 'value-format)
99 (setq fn feature-name)
100 (while (and (setq parent (char-feature-name-parent fn))
102 (or (char-feature-property
103 parent 'value-presentation-format)
104 (char-feature-property
105 parent 'value-format)))))
108 (let ((type (www-feature-type feature-name)))
109 (cond ((eq type 'relation)
111 ((eq type 'structure)
112 'space-separated-ids)
116 (if (find-charset feature-name)
117 (if (and (= (charset-dimension feature-name) 2)
118 (= (charset-chars feature-name) 94))
120 " (" (decimal) ") <" (ku-ten) "> " (prev-char) (next-char))
121 '("0x" (HEX) " (" (decimal) ") " (prev-char) (next-char))))
124 (defun char-feature-name-at-domain (feature-name domain)
126 (let ((name (symbol-name feature-name)))
128 ((string-match "@[^*]+$" name)
129 (intern (format "%s/%s" name domain))
132 (intern (format "%s@%s" name domain))
136 (defun char-feature-name-parent (feature-name)
137 (let ((name (symbol-name feature-name)))
138 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
139 (intern (substring name 0 (car (last (match-data) 2)))))))
141 (defun char-feature-name-domain (feature-name)
142 (let ((name (symbol-name feature-name)))
143 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
144 (intern (substring name (1+ (match-beginning 0)))))))
146 (defun char-feature-name-sans-versions (feature)
147 (let ((feature-name (symbol-name feature)))
148 (if (string-match "[@/]\\$rev=latest$" feature-name)
149 (intern (substring feature-name 0 (match-beginning 0)))
152 (defun est-object-genre (object)
153 (if (characterp object)
155 (concord-object-genre object)))
157 (defun www-get-feature-value (object feature)
158 (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest)))
161 (mount-char-attribute-table latest-feature)
162 (or (char-feature object latest-feature)
163 (char-feature object feature))
166 (or (condition-case nil
167 (concord-object-get object latest-feature)
170 (concord-object-get object feature)
174 (defun get-previous-code-point (ccs code)
175 (let ((chars (charset-chars ccs))
176 (dim (charset-dimension ccs))
178 mask byte-min byte-max
201 (setq bytes (make-vector dim 0))
203 (aset bytes i (logand (lsh code (* i -8)) mask))
206 (while (and (< i dim)
208 (aset bytes i (1- (aref bytes i)))
209 (< (aref bytes i) byte-min)))
210 (aset bytes i byte-max)
213 (setq dest (aref bytes 0)
216 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
220 (defun get-next-code-point (ccs code)
221 (let ((chars (charset-chars ccs))
222 (dim (charset-dimension ccs))
224 mask byte-min byte-max
247 (setq bytes (make-vector dim 0))
249 (aset bytes i (logand (lsh code (* i -8)) mask))
252 (while (and (< i dim)
254 (aset bytes i (1+ (aref bytes i)))
255 (> (aref bytes i) byte-max)))
256 (aset bytes i byte-min)
259 (setq dest (aref bytes 0)
262 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
266 (defun find-previous-defined-code-point (ccs code)
267 (let ((i (get-previous-code-point ccs code))
270 ((eq ccs '=jis-x0208)
271 (setq ccs '=jis-x0208@1990))
272 ((eq ccs '=jis-x0213-1)
273 (setq ccs '=jis-x0213-1@2004)))
276 (null (setq char (decode-char ccs i
277 (unless (eq ccs '=ucs)
279 (setq i (get-previous-code-point ccs i)))
282 (defun find-next-defined-code-point (ccs code)
283 (let ((i (get-next-code-point ccs code))
285 (setq max (+ code 1000))
287 ((eq ccs '=jis-x0208)
288 (setq ccs '=jis-x0208@1990))
289 ((eq ccs '=jis-x0213-1)
290 (setq ccs '=jis-x0213-1@2004)))
293 (null (setq char (decode-char ccs i
294 (unless (eq ccs '=ucs)
296 (setq i (get-next-code-point ccs i)))
300 ;;; @ URI representation
303 (defun www-uri-decode-feature-name (uri-feature)
305 (setq uri-feature (decode-uri-string uri-feature 'utf-8-mcs-er))
307 ((string-match "^from\\." uri-feature)
308 (intern (format "<-%s" (substring uri-feature (match-end 0))))
310 ((string-match "^to\\." uri-feature)
311 (intern (format "->%s" (substring uri-feature (match-end 0))))
313 ((string-match "^rep\\." uri-feature)
314 (intern (format "=%s" (substring uri-feature (match-end 0))))
316 ((string-match "^g\\." uri-feature)
317 (intern (format "=>>%s" (substring uri-feature (match-end 0))))
319 ((string-match "^gi\\." uri-feature)
320 (intern (format "=>>>%s" (substring uri-feature (match-end 0))))
322 ((string-match "^gi\\([0-9]+\\)\\." uri-feature)
323 (intern (format "=>>%s%s"
324 (make-string (string-to-int
325 (match-string 1 uri-feature))
327 (substring uri-feature (match-end 0))))
329 ((string-match "^o\\." uri-feature)
330 (intern (format "=+>%s" (substring uri-feature (match-end 0))))
332 ((string-match "^a\\." uri-feature)
333 (intern (format "=>%s" (substring uri-feature (match-end 0))))
335 ((string-match "^a\\([0-9]+\\)\\." uri-feature)
336 (intern (format "%s>%s"
337 (make-string (string-to-int
338 (match-string 1 uri-feature))
340 (substring uri-feature (match-end 0))))
342 ((and (setq feature (intern (format "=>%s" uri-feature)))
343 (find-charset feature))
345 ((and (setq feature (intern (format "=>>%s" uri-feature)))
346 (find-charset feature))
348 ((and (setq feature (intern (format "=>>>%s" uri-feature)))
349 (find-charset feature))
351 ((and (setq feature (intern (format "=%s" uri-feature)))
352 (find-charset feature))
354 (t (intern uri-feature)))))
356 (defun www-uri-encode-feature-name (feature-name)
357 (setq feature-name (symbol-name feature-name))
359 ((string-match "^=\\+>\\([^=>]+\\)" feature-name)
360 (concat "o." (substring feature-name (match-beginning 1)))
362 ((string-match "^=\\([^=>]+\\)" feature-name)
363 (concat "rep." (substring feature-name (match-beginning 1)))
365 ((string-match "^=>>\\([^=>]+\\)" feature-name)
366 (concat "g." (substring feature-name (match-beginning 1)))
368 ((string-match "^=>>>\\([^=>]+\\)" feature-name)
369 (concat "gi." (substring feature-name (match-beginning 1)))
371 ((string-match "^=>>\\(>+\\)" feature-name)
373 (length (match-string 1 feature-name))
374 (substring feature-name (match-end 1)))
376 ((string-match "^=>\\([^=>]+\\)" feature-name)
377 (concat "a." (substring feature-name (match-beginning 1)))
379 ((string-match "^\\(=+\\)>" feature-name)
381 (length (match-string 1 feature-name))
382 (substring feature-name (match-end 0)))
384 ((string-match "^->" feature-name)
385 (concat "to." (substring feature-name (match-end 0)))
387 ((string-match "^<-" feature-name)
388 (concat "from." (substring feature-name (match-end 0)))
392 (defun www-uri-make-feature-name-url (uri-genre uri-feature-name uri-object)
393 (format "%s?feature=%s&%s=%s"
394 chise-wiki-view-url uri-feature-name uri-genre uri-object))
396 (defun www-uri-decode-object (genre char-rep)
399 ((string-match "\\(%3A\\|:\\)" char-rep)
400 (setq ccs (substring char-rep 0 (match-beginning 0))
401 cpos (substring char-rep (match-end 0)))
402 (setq ccs (www-uri-decode-feature-name ccs))
404 ((string-match "^0x" cpos)
406 (string-to-number (substring cpos (match-end 0)) 16))
409 (setq cpos (car (read-from-string
411 cpos file-name-coding-system))))
413 (if (and (eq genre 'character)
415 (decode-char ccs cpos)
416 (concord-decode-object ccs cpos genre))
419 (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
421 ((eq genre 'character)
422 (when (= (length char-rep) 1)
426 (concord-decode-object
427 '=id (www-uri-decode-feature-name char-rep) 'feature)
430 (concord-decode-object
431 '=id (car (read-from-string char-rep)) genre)
434 (defun www-uri-encode-object (object)
435 (if (characterp object)
436 (if (encode-char object '=ucs)
439 (format "%%%02X" byte))
440 (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
442 (let ((ccs-list '(; =ucs
443 =cns11643-1 =cns11643-2 =cns11643-3
444 =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
446 =jis-x0208 =jis-x0208@1990
451 =jis-x0213-1@2000 =jis-x0213-1@2004
452 =jis-x0208@1983 =jis-x0208@1978
453 =zinbun-oracle =>zinbun-oracle
457 =>>>jis-x0208 =>>>jis-x0213-1 =>>>jis-x0213-2
458 =>>jis-x0208 =>>jis-x0213-1 =>>jis-x0213-2
460 =+>jis-x0208 =+>jis-x0213-1 =+>jis-x0213-2
463 =>jis-x0208 =>jis-x0213-1
465 =>ucs@iso =>ucs@unicode
466 =>ucs@jis =>ucs@cns =>ucs@ks
467 =>>ucs@iso =>>ucs@unicode
468 =>>ucs@jis =>>ucs@cns =>>ucs@ks
469 =>>>ucs@iso =>>>ucs@unicode
470 =>>>ucs@jis =>>>ucs@cns =>>>ucs@ks
476 (setq ccs (pop ccs-list))
477 (not (setq ret (encode-char object ccs 'defined-only)))))
480 (www-uri-encode-feature-name ccs)
482 ((and (setq ccs (car (split-char object)))
483 (setq ret (encode-char object ccs)))
485 (www-uri-encode-feature-name ccs)
488 (format "system-char-id:0x%X"
489 (encode-char object 'system-char-id))
491 (format "rep.id:%s" (concord-object-id object))))
493 (defun est-format-object (object &optional readable)
494 (if (characterp object)
495 (char-to-string object)
496 (let ((ret (or (if readable
497 (or (concord-object-get object 'name)
498 (concord-object-get object '=name)
499 (concord-object-get object 'title)))
500 (concord-object-id object))))
503 (defun www-uri-make-object-url (object &optional uri-object)
506 (est-object-genre object)
508 (www-uri-encode-object object))))
511 ;;; @ Feature name presentation
514 (defun www-format-feature-name-default (feature-name)
518 (symbol-name feature-name)
522 (defun www-format-feature-name-as-metadata (feature-name &optional lang)
523 (let ((str (symbol-name feature-name))
526 ((string-match "\\*[^*]+$" str)
527 (setq base (substring str 0 (match-beginning 0))
528 meta (substring str (match-beginning 0)))
529 (concat (www-format-feature-name* (intern base) lang)
532 (www-format-feature-name-default feature-name)
535 (defun www-format-feature-name-as-rel-to (feature-name)
536 (concat "\u2192" (substring (symbol-name feature-name) 2)))
538 (defun www-format-feature-name-as-rel-from (feature-name)
539 (concat "\u2190" (substring (symbol-name feature-name) 2)))
541 (defun www-format-feature-name-as-CCS (feature-name)
544 (symbol-name feature-name)
546 (dest (upcase (pop rest))))
547 (when (string-match "^=+>*" dest)
548 (setq dest (concat (substring dest 0 (match-end 0))
550 (substring dest (match-end 0)))))
554 (setq dest (concat dest " " (upcase (pop rest)))))
555 (if (string-match "^[0-9]+$" (car rest))
556 (concat dest "-" (car rest))
557 (concat dest " " (upcase (car rest))))
561 (defun www-format-feature-name* (feature-name &optional lang)
562 (let (name fn parent ret)
565 (char-feature-property
567 (intern (format "name@%s" lang))))
568 (char-feature-property
569 feature-name 'name)))
570 ((and (setq name (symbol-name feature-name))
571 (string-match "\\*" name))
572 (www-format-feature-name-as-metadata feature-name lang))
574 (setq fn feature-name)
575 (while (and (setq parent (char-feature-name-parent fn))
578 (char-feature-property
580 (intern (format "name@%s" lang))))
581 (char-feature-property
586 (concat ret (substring (symbol-name feature-name)
587 (length (symbol-name parent)))))
588 ((find-charset feature-name)
589 (www-format-feature-name-as-CCS feature-name))
590 ((string-match "^\\(->\\)" name)
591 (www-format-feature-name-as-rel-to feature-name))
592 ((string-match "^\\(<-\\)" name)
593 (www-format-feature-name-as-rel-from feature-name))
595 (www-format-feature-name-default feature-name)
599 (defun www-format-feature-name (feature-name &optional lang)
600 (www-format-encode-string
601 (www-format-feature-name* feature-name lang)))
607 (defvar www-format-char-img-style "vertical-align:bottom;")
609 (defun www-format-encode-string (string &optional without-tags as-body)
612 (let (plane code start end char variants ret rret)
614 (goto-char (point-min))
615 (while (search-forward "&" nil t)
616 (replace-match "&" nil t)))
617 (goto-char (point-min))
618 (while (search-forward "<" nil t)
619 (replace-match "<" nil t))
620 (goto-char (point-min))
621 (while (search-forward ">" nil t)
622 (replace-match ">" nil t))
624 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
625 (let ((coded-charset-entity-reference-alist
628 '(=cns11643-1 "C1-" 4 X)
629 '(=cns11643-2 "C2-" 4 X)
630 '(=cns11643-3 "C3-" 4 X)
631 '(=cns11643-4 "C4-" 4 X)
632 '(=cns11643-5 "C5-" 4 X)
633 '(=cns11643-6 "C6-" 4 X)
634 '(=cns11643-7 "C7-" 4 X)
636 '(=gb12345 "G1-" 4 X)
637 '(=jis-x0208@1990 "J90-" 4 X)
638 '(=jis-x0212 "JSP-" 4 X)
640 '(=jis-x0208@1997 "J97-" 4 X)
641 '(=jis-x0208@1978 "J78-" 4 X)
642 '(=jis-x0208@1983 "J83-" 4 X)
643 '(=ruimoku-v6 "RUI6-" 4 X)
644 '(=zinbun-oracle "ZOB-" 4 d)
645 '(=jef-china3 "JC3-" 4 X)
646 '(=daikanwa "M-" 5 d)
647 coded-charset-entity-reference-alist)))
648 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
650 (goto-char (point-min))
651 (while (re-search-forward "&CB\\([0-9]+\\);" nil t)
652 (setq code (string-to-int (match-string 1)))
654 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
657 chise-wiki-bitmap-glyphs-url
659 www-format-char-img-style)
662 (goto-char (point-min))
663 (while (re-search-forward "&\\(o-\\)?J\\(78\\|83\\|90\\|97\\|SP\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
664 (setq plane (match-string 2)
665 code (string-to-int (match-string 3) 16))
667 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
670 chise-wiki-bitmap-glyphs-url
673 (- (logand code 255) 32)
674 www-format-char-img-style)
677 (goto-char (point-min))
678 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
679 (setq plane (string-to-int (match-string 1))
680 code (string-to-int (match-string 2) 16))
682 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
685 chise-wiki-bitmap-glyphs-url
688 (- (logand code 255) 32)
689 www-format-char-img-style)
692 (goto-char (point-min))
693 (while (re-search-forward "&C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
694 (setq plane (string-to-int (match-string 1))
695 code (string-to-int (match-string 2) 16))
697 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
700 chise-wiki-bitmap-glyphs-url
702 www-format-char-img-style)
705 (goto-char (point-min))
706 (while (re-search-forward "&JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
707 (setq code (string-to-int (match-string 1) 16))
709 (format "<img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">"
713 (goto-char (point-min))
714 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
715 (setq code (string-to-int (match-string 2)))
717 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
718 style=\"vertical-align:middle\">"
720 chise-wiki-bitmap-glyphs-url
722 www-format-char-img-style)
725 (goto-char (point-min))
726 (while (re-search-forward "&\\(G-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
727 (setq code (string-to-int (match-string 2)))
729 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
732 chise-wiki-glyph-cgi-url
734 www-format-char-img-style)
737 (goto-char (point-min))
738 (while (re-search-forward "&\\(G-\\)?GT-K\\([0-9]+\\);" nil t)
739 (setq code (string-to-int (match-string 2)))
741 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
744 chise-wiki-glyph-cgi-url
746 www-format-char-img-style)
749 (goto-char (point-min))
750 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
751 (setq code (string-to-int (match-string 1) 16))
753 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
756 chise-wiki-glyph-cgi-url
758 www-format-char-img-style)
761 (goto-char (point-min))
762 (while (re-search-forward "&CDP-\\([0-9A-F]+\\);" nil t)
763 (setq code (string-to-int (match-string 1) 16))
765 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
768 chise-wiki-glyph-cgi-url
770 www-format-char-img-style)
773 (goto-char (point-min))
774 (while (re-search-forward "&RUI6-\\([0-9A-F]+\\);" nil t)
775 (setq code (string-to-int (match-string 1) 16))
777 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
778 style=\"vertical-align:middle\">"
780 chise-wiki-glyph-cgi-url
782 www-format-char-img-style)
785 (goto-char (point-min))
786 (while (re-search-forward "&\\(A-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
787 (setq code (string-to-int (match-string 3) 16))
789 (format "<img alt=\"UU+%04X\" src=\"http://www.unicode.org/cgi-bin/refglyph?24-%04X\"
790 style=\"vertical-align:middle\">"
793 www-format-char-img-style)
796 (goto-char (point-min))
797 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
798 (setq code (string-to-int (match-string 1) 16))
799 (setq start (match-beginning 0)
801 (setq char (decode-char 'system-char-id code))
804 (or (www-get-feature-value char '->subsumptive)
805 (www-get-feature-value char '->denotational)))
808 (setq ret (www-format-encode-string
809 (char-to-string (car variants))))
810 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
811 (setq variants (cdr variants)))
813 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
815 (delete-region start end)
818 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
819 (www-get-feature-value char 'ideographic-structure)))
824 (if (characterp (setq rret (find-char ch)))
827 (www-format-encode-string
828 (char-to-string ch) without-tags)
829 (www-format-encode-string
830 (format "%S" ch) without-tags)))
834 (delete-region start end)
838 ;; (goto-char (point-min))
839 ;; (while (search-forward ">-" nil t)
840 ;; (replace-match "&GT-" t 'literal))
843 (defun www-html-display-text (text)
847 (goto-char (point-min))
848 (while (search-forward "<" nil t)
849 (replace-match "<" nil t))
850 (goto-char (point-min))
851 (while (search-forward ">" nil t)
852 (replace-match ">" nil t))
853 (goto-char (point-min))
854 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
856 (format "<a href=\"%s\">%s</a>"
860 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
861 (goto-char (point-min))
862 (while (search-forward ">-" nil t)
863 (replace-match "&GT-" nil t))
866 (defun www-html-display-paragraph (text)
868 (www-html-display-text text)
875 (defvar coded-charset-GlyphWiki-id-alist
877 (=adobe-japan1-0 "aj1-" 5 d nil)
878 (=adobe-japan1-1 "aj1-" 5 d nil)
879 (=adobe-japan1-2 "aj1-" 5 d nil)
880 (=adobe-japan1-3 "aj1-" 5 d nil)
881 (=adobe-japan1-4 "aj1-" 5 d nil)
882 (=adobe-japan1-5 "aj1-" 5 d nil)
883 (=adobe-japan1-6 "aj1-" 5 d nil)
885 (=decomposition@hanyo-denshi)
886 (=hanyo-denshi/ks "koseki-" 6 d nil)
887 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
888 (=ucs@jis "u" 4 x nil)
889 (=ucs@cns "u" 4 x "-t")
890 (=jis-x0212 "jsp-" 4 x nil)
891 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
892 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
893 (=jis-x0213-2 "jx2-" 4 x nil)
895 (=daikanwa "dkw-" 5 d nil)
896 (=>>daikanwa "dkw-" 5 d nil)
897 (=gt-k "gt-k" 5 d nil)
898 (=jef-china3 "jc3-" 4 x nil)
900 (=ks-x1001 "k0-" 4 x nil)
901 (=jis-x0208@1978/1pr "j78-" 4 x nil)
902 (=jis-x0208@1978/-4pr "j78-" 4 x nil)
903 (=jis-x0208@1978 "j78-" 4 x nil)
904 (=>>>jis-x0208@1978 "j78-" 4 x nil)
905 (=>>jis-x0208@1978 "j78-" 4 x nil)
906 (=+>jis-x0208@1978 "j78-" 4 x nil)
907 (=ucs@JP "u" 4 x nil)
908 (=ucs@gb "u" 4 x "-g")
909 (=ucs@ks "u" 4 x "-k")
910 (=ucs@iso "u" 4 x "-u")
911 (=ucs@unicode "u" 4 x "-us")
912 (=big5-cdp "cdp-" 4 x nil)
913 (=>>big5-cdp "cdp-" 4 x nil)
914 (=cns11643-1 "c1-" 4 x nil)
915 (=cns11643-2 "c2-" 4 x nil)
916 (=cns11643-3 "c3-" 4 x nil)
917 (=cns11643-4 "c4-" 4 x nil)
918 (=cns11643-5 "c5-" 4 x nil)
919 (=cns11643-6 "c6-" 4 x nil)
920 (=cns11643-7 "c7-" 4 x nil)
921 (=jis-x0208 "j90-" 4 x nil)
922 (=>>>jis-x0208 "j90-" 4 x nil)
923 (=>>jis-x0208 "j90-" 4 x nil)
924 (=+>jis-x0208 "j90-" 4 x nil)
925 (=jis-x0208@1990 "j90-" 4 x nil)
926 (=>>>jis-x0208@1990 "j90-" 4 x nil)
927 (=>>jis-x0208@1990 "j90-" 4 x nil)
928 (=+>jis-x0208@1990 "j90-" 4 x nil)
929 (=jis-x0208@1983 "j83-" 4 x nil)
930 (=>>>jis-x0208@1983 "j83-" 4 x nil)
931 (=>>jis-x0208@1983 "j83-" 4 x nil)
932 (=+>jis-x0208@1983 "j83-" 4 x nil)
933 (=cbeta "cb" 5 d nil)
936 (defun char-GlyphWiki-id (char)
937 (let ((rest coded-charset-GlyphWiki-id-alist)
940 (setq spec (pop rest))
941 (null (setq ret (char-feature char (car spec))))))
945 (mapconcat #'char-GlyphWiki-id ret "-"))
946 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
948 ((and (or (encode-char char '=jis-x0208@1990)
949 (encode-char char '=jis-x0212)
950 (encode-char char '=jis-x0213-1))
951 (setq code (encode-char char '=ucs@jis)))
952 (format "u%04x" code)
954 ((and (or (encode-char char '=gb2312)
955 (encode-char char '=gb12345))
956 (setq code (encode-char char '=ucs@gb)))
957 (format "u%04x-g" code)
959 ((and (or (encode-char char '=cns11643-1)
960 (encode-char char '=cns11643-2)
961 (encode-char char '=cns11643-3)
962 (encode-char char '=cns11643-4)
963 (encode-char char '=cns11643-5)
964 (encode-char char '=cns11643-6)
965 (encode-char char '=cns11643-7))
966 (setq code (encode-char char '=ucs@cns)))
967 (format "u%04x-t" code)
969 ((and (encode-char char '=ks-x1001)
970 (setq code (encode-char char '=ucs@ks)))
971 (format "u%04x-k" code)
973 (format (format "%s%%0%d%s%s"
977 (or (nth 4 spec) ""))
984 (provide 'cwiki-common)
986 ;;; cwiki-common.el ends here