Mount `->HNG' and `<-HNG'.
authorMORIOKA Tomohiko <tomo.git@chise.org>
Wed, 21 Oct 2015 08:48:04 +0000 (17:48 +0900)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Wed, 21 Oct 2015 08:48:04 +0000 (17:48 +0900)
(chise-wiki-hng-bitmap-glyphs-url): New variable.
(www-format-encode-string):
- Format "&(o-|G-|g2-|R-)J0-hhhh;".
- Format "R-HD-*;".
- Format "&HNGdd-ddddd;".
- Format "&(o-|G-|g2-|R-)MJ-dddddd;".
- Format "&(G-|g2-|R-)CDP-hhhh;".

cwiki-common.el

index ed51c57..07ae80c 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")
@@ -41,6 +45,9 @@
 (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")
 
 (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)
@@ -829,7 +836,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 +864,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 +877,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 +937,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 +968,17 @@ 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 "&\\(G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
            (setq code (string-to-int (match-string 2)))
            (replace-match
@@ -965,8 +1015,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\">"