(est-coded-charset-priority-list): Add `=mj', `==mj', `===mj' and
[chise/est.git] / cwiki-common.el
index ed51c57..2579d22 100644 (file)
 (mount-char-attribute-table '*instance@morpheme-entry/zh-classical)
 
 
+(mount-char-attribute-table '->HNG)
+(mount-char-attribute-table '<-HNG)
+
+
 (defvar est-hide-cgi-mode nil)
 (defvar est-view-url-prefix "..")
 (defvar chise-wiki-view-url "view.cgi")
 (defvar chise-wiki-bitmap-glyphs-url
   "http://www.chise.org/glyphs")
 
+(defvar chise-wiki-hng-bitmap-glyphs-url
+  "http://hng.chise.org/glyphs/HNG")
+
 (defvar chise-wiki-glyph-cgi-url
   "http://www.chise.org/chisewiki/glyph.cgi")
 
 (defvar chise-wiki-displayed-features nil)
 
+(defvar est-coded-charset-priority-list
+  '(; =ucs
+    =cns11643-1 =cns11643-2 =cns11643-3
+    =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
+    =gb2312 =gb12345
+    =jis-x0208 =jis-x0208@1990
+    =jis-x0213-2
+    =jis-x0212
+    =adobe-japan1
+    =cbeta =jef-china3
+    =jis-x0213-1@2000 =jis-x0213-1@2004
+    =jis-x0208@1983 =jis-x0208@1978
+    =zinbun-oracle =>zinbun-oracle
+    =daikanwa
+    =gt =gt-k
+    =>>>adobe-japan1
+    =>>>jis-x0208 =>>>jis-x0213-1 =>>>jis-x0213-2
+    =>>jis-x0208 =>>jis-x0213-1 =>>jis-x0213-2
+    =>>adobe-japan1
+    =+>jis-x0208 =+>jis-x0213-1 =+>jis-x0213-2
+    =+>jis-x0208@1978
+    =+>adobe-japan1
+    =>jis-x0208 =>jis-x0213-1
+    =>>gt
+    =>ucs@iso =>ucs@unicode
+    =>ucs@jis =>ucs@cns =>ucs@ks
+    =>>ucs@iso =>>ucs@unicode
+    =>>ucs@jis =>>ucs@cns =>>ucs@ks
+    =>>>ucs@iso =>>>ucs@unicode
+    =>>>ucs@jis =>>>ucs@cns =>>>ucs@ks
+    ===ucs@iso
+    =ruimoku-v6
+    =big5
+    =big5-cdp
+    =>cbeta
+    =mj
+    ==mj
+    ===mj
+    =ucs-itaiji-001
+    =ucs-itaiji-002
+    =ucs-itaiji-003))
+
 (defun decode-uri-string (string &optional coding-system)
   (if (> (length string) 0)
       (let ((i 0)
         ))))
 
 (defun www-feature-format (feature-name)
-  (or (char-feature-property feature-name 'format)
+  (or (char-feature-property feature-name 'presentation-format)
+      (char-feature-property feature-name 'format)
       (let (fn parent ret)
        (setq fn feature-name)
        (while (and (setq parent (char-feature-name-parent fn))
             (format "%%%02X" byte))
           (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
           "")
-       (let ((ccs-list '(; =ucs
-                         =cns11643-1 =cns11643-2 =cns11643-3
-                         =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
-                         =gb2312 =gb12345
-                         =jis-x0208 =jis-x0208@1990
-                         =jis-x0213-2
-                         =jis-x0212
-                         =adobe-japan1
-                         =cbeta =jef-china3
-                         =jis-x0213-1@2000 =jis-x0213-1@2004
-                         =jis-x0208@1983 =jis-x0208@1978
-                         =zinbun-oracle =>zinbun-oracle
-                         =daikanwa
-                         =gt =gt-k
-                         =>>>adobe-japan1
-                         =>>>jis-x0208 =>>>jis-x0213-1 =>>>jis-x0213-2
-                         =>>jis-x0208 =>>jis-x0213-1 =>>jis-x0213-2
-                         =>>adobe-japan1
-                         =+>jis-x0208 =+>jis-x0213-1 =+>jis-x0213-2
-                         =+>jis-x0208@1978
-                         =+>adobe-japan1
-                         =>jis-x0208 =>jis-x0213-1
-                         =>>gt
-                         =>ucs@iso =>ucs@unicode
-                         =>ucs@jis =>ucs@cns =>ucs@ks
-                         =>>ucs@iso =>>ucs@unicode
-                         =>>ucs@jis =>>ucs@cns =>>ucs@ks
-                         =>>>ucs@iso =>>>ucs@unicode
-                         =>>>ucs@jis =>>>ucs@cns =>>>ucs@ks
-                         =ruimoku-v6
-                         =big5
-                         =big5-cdp))
+       (let ((ccs-list est-coded-charset-priority-list)
              ccs ret)
          (while (and ccs-list
                      (setq ccs (pop ccs-list))
 (defun www-format-encode-string (string &optional without-tags as-body)
   (with-temp-buffer
     (insert string)
-    (let (plane code start end char variants ret rret)
+    (let (plane code subcode start end char variants ret rret)
       (when as-body
        (goto-char (point-min))
        (while (search-forward "&" nil t)
          (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
 
          (goto-char (point-min))
-         (while (re-search-forward "&CB\\([0-9]+\\);" nil t)
-           (setq code (string-to-int (match-string 1)))
+         (while (re-search-forward "&\\(A-\\)?CB\\([0-9]+\\);" nil t)
+           (setq code (string-to-int (match-string 2)))
            (replace-match
             (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
 style=\"%s\">"
@@ -829,7 +848,20 @@ style=\"%s\">"
             t 'literal))
 
          (goto-char (point-min))
-         (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?HD-\\(JA\\|JB\\|JC\\|JD\\|FT\\|IA\\|IB\\|HG\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
+         (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?J0-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
+           (setq code (string-to-int (match-string 2) 16))
+           (replace-match
+            (format "<img alt=\"J0-%04X\" src=\"%s/JIS-90/%02d-%02d.gif\"
+style=\"%s\">"
+                    code
+                    chise-wiki-bitmap-glyphs-url
+                    (- (lsh code -8) 32)
+                    (- (logand code 255) 32)
+                    www-format-char-img-style)
+            t 'literal))
+
+         (goto-char (point-min))
+         (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-\\(JA\\|JB\\|JC\\|JD\\|FT\\|IA\\|IB\\|HG\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
            (setq plane (match-string 2)
                  code (string-to-int (match-string 3) 16))
            (replace-match
@@ -844,7 +876,7 @@ style=\"%s\">"
             t 'literal))
 
          (goto-char (point-min))
-         (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?HD-\\(IP\\|JT\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
+         (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-\\(IP\\|JT\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
            (setq plane (match-string 2)
                  code (string-to-int (match-string 3) 16))
            (replace-match
@@ -857,7 +889,7 @@ style=\"%s\">"
             t 'literal))
 
          (goto-char (point-min))
-         (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?HD-KS-\\([0-9]+\\);" nil t)
+         (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-KS-\\([0-9]+\\);" nil t)
            (setq code (string-to-int (match-string 2)))
            (replace-match
             (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
@@ -917,6 +949,25 @@ style=\"vertical-align:middle\">"
             t 'literal))
 
          (goto-char (point-min))
+         (while (re-search-forward "&HNG\\([0-9]+\\)-\\([0-9][0-9][0-9][0-9]\\)\\([0-9]\\);" nil t)
+           (setq plane (match-string 1)
+                 code (string-to-int (match-string 2))
+                 subcode (string-to-int (match-string 3)))
+           (setq subcode
+                 (if (eq subcode 0)
+                     ""
+                   (char-to-string (decode-char 'ascii (+ 96 subcode)))))
+           (replace-match
+            (format
+             "<img alt=\"HNG%s-%04d%s\" src=\"%s/%s/%04d%s.png\"
+style=\"vertical-align:middle; width: 48px; height: 48px\">"
+             plane code subcode
+             chise-wiki-hng-bitmap-glyphs-url
+             plane code subcode
+             www-format-char-img-style)
+            t 'literal))
+
+         (goto-char (point-min))
          (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?AJ1-\\([0-9]+\\);" nil t)
            (setq code (string-to-int (match-string 2)))
            (replace-match
@@ -929,6 +980,42 @@ style=\"vertical-align:middle\">"
             t 'literal))
 
          (goto-char (point-min))
+         (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?MJ\\([0-9]+\\);" nil t)
+           (setq code (string-to-int (match-string 2)))
+           (replace-match
+            (format "<img alt=\"MJ%06d\" src=\"http://mojikiban.ipa.go.jp/search/MJ%06d\"
+style=\"vertical-align:middle; width: 48px; height: 48px\">"
+                    code
+                    code
+                    www-format-char-img-style)
+            t 'literal))
+
+         (goto-char (point-min))
+         (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?IU-\\([0-9A-F]+\\);" nil t)
+           (setq code (string-to-int (match-string 2) 16))
+           (replace-match
+            (format "<img alt=\"u%04x\" src=\"http://glyphwiki.org/glyph/u%04x.100px.png\"
+style=\"vertical-align:middle; width: 48px; height: 48px\">"
+                    code
+                    code
+                    www-format-char-img-style)
+            t 'literal))
+
+         (goto-char (point-min))
+         (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?U-i\\([0-9]+\\)\\+\\([0-9A-F]+\\);" nil t)
+           (setq plane (string-to-int (match-string 2))
+                 code (string-to-int (match-string 3) 16))
+           (replace-match
+            (format "<img alt=\"u%04x-itaiji-%03d\" src=\"http://glyphwiki.org/glyph/u%04x-itaiji-%03d.100px.png\"
+style=\"vertical-align:middle; width: 48px; height: 48px\">"
+                    code
+                    plane
+                    code
+                    plane
+                    www-format-char-img-style)
+            t 'literal))
+
+         (goto-char (point-min))
          (while (re-search-forward "&\\(G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
            (setq code (string-to-int (match-string 2)))
            (replace-match
@@ -965,8 +1052,8 @@ style=\"%s\">"
             t 'literal))
 
          (goto-char (point-min))
-         (while (re-search-forward "&CDP-\\([0-9A-F]+\\);" nil t)
-           (setq code (string-to-int (match-string 1) 16))
+         (while (re-search-forward "&\\(G-\\|g2-\\|R-\\)?CDP-\\([0-9A-F]+\\);" nil t)
+           (setq code (string-to-int (match-string 2) 16))
            (replace-match
             (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
 style=\"%s\">"
@@ -1091,7 +1178,14 @@ style=\"vertical-align:middle\">"
 ;;;
 
 (defvar coded-charset-GlyphWiki-id-alist
-  '((=ucs              "u"     4 x nil)
+  '((=ucs-var-001      "u"     4 x "-var-001")
+    (=ucs-var-002      "u"     4 x "-var-002")
+    (=ucs-var-003      "u"     4 x "-var-003")
+    (=ucs-itaiji-001   "u"     4 x "-itaiji-001")
+    (=ucs-itaiji-002   "u"     4 x "-itaiji-002")
+    (=ucs-itaiji-003   "u"     4 x "-itaiji-003")
+    (=ucs-itaiji-084   "u"     4 x "-itaiji-084")
+    (=ucs              "u"     4 x nil)
     (=adobe-japan1-0   "aj1-"  5 d nil)
     (=adobe-japan1-1   "aj1-"  5 d nil)
     (=adobe-japan1-2   "aj1-"  5 d nil)
@@ -1117,8 +1211,10 @@ style=\"vertical-align:middle\">"
     (=decomposition@hanyo-denshi)
     (=hanyo-denshi/ks  "koseki-" 6 d nil)
     (=>>hanyo-denshi/ks        "koseki-" 6 d nil)
+    (=koseki           "koseki-" 6 d nil)
     (=ucs@jis          "u"     4 x nil)
     (==ucs@jis         "u"     4 x nil)
+    (==ucs@iso         "u"     4 x nil)
     (===ucs@jis                "u"     4 x nil)
     (=ucs@cns          "u"     4 x "-t")
     (==ucs@cns         "u"     4 x "-t")
@@ -1170,6 +1266,8 @@ style=\"vertical-align:middle\">"
     (=+>jis-x0208@1983 "j83-"  4 x nil)
     (=cbeta            "cb"    5 d nil)
     (=>>daikanwa       "dkw-"  5 d nil)
+    (=big5-cdp-var-3   "cdp-"  4 x "-var-3")
+    (=big5-cdp-var-5   "cdp-"  4 x "-var-5")
     ))
 
 (defun char-GlyphWiki-id (char)