(www-display-object-desc):
authorMORIOKA Tomohiko <tomo.git@chise.org>
Fri, 14 Jan 2022 08:35:29 +0000 (17:35 +0900)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Sat, 15 Jan 2022 16:23:49 +0000 (01:23 +0900)
- Add code to link HDIC Viewer from HDIC-TSJ characters.
- New implementation to add clickable image of clipped source image
  for `=shuowen-jiguge', `===shuowen-jiguge5' and `===shuowen-jiguge4'
  characters.

cwiki-view.el

index ba15468..f3830a0 100644 (file)
@@ -302,18 +302,39 @@ li { margin: 0 0 0 2em; }
           (format "<img alt=\"%s\" src=\"%s\" />"
                   ret ret)))
        )
+       ((and (eq genre 'character)
+            (setq ret (or (encode-char object '=chise-hdic-tsj)
+                          (encode-char object '===chise-hdic-tsj)))
+            (setq ret (decode-char '===chise-hdic-tsj ret))
+            (setq ret (get-char-attribute ret '=hdic-tsj-entry-id)))
+       (princ
+        (format "<a href=\"https://viewer.hdic.jp/tsj2/%s\"
+>%s</a>"
+                ret
+                (www-format-encode-string
+                 (est-format-object object 'readable))))
+       )
        ((or (and (eq genre 'glyph-image)
                 (setq image-cobj
                       (car (concord-object-get object '->image-resource))))
            (and (eq genre 'character)
-                (setq ret (www-format-encode-string
-                           (est-format-object object 'readable)))
-                (string-match
-                 "<img alt=\"SW-JIGUGE\\([45]\\)-\\([0-9][0-9][0-9]\\)\\([0-9][0-9]\\)"
-                 ret)
-                (setq item-code (string-to-int (match-string 1 ret))
-                      page (string-to-int (match-string 2 ret))
-                      char-num (string-to-int (match-string 3 ret)))
+                 ;; (setq ret (www-format-encode-string
+                 ;;            (est-format-object object 'readable)))
+                 ;; (string-match
+                 ;;  "<img alt=\"SW-JIGUGE\\([45]\\)-\\([0-9][0-9][0-9]\\)\\([0-9][0-9]\\)"
+                 ;;  ret)
+                 ;; (setq item-code (string-to-int (match-string 1 ret))
+                 ;;       page (string-to-int (match-string 2 ret))
+                 ;;       char-num (string-to-int (match-string 3 ret)))
+                (cond ((setq ret (or (encode-char object '=shuowen-jiguge)
+                                     (encode-char object '===shuowen-jiguge5)))
+                       (setq item-code 5
+                             page     (/ ret 100)
+                             char-num (% ret 100)))
+                      ((setq ret (encode-char object '===shuowen-jiguge4))
+                       (setq item-code 4
+                             page     (/ ret 100)
+                             char-num (% ret 100))))
                 (setq glyph-image-id
                       (cond ((eq item-code 4)
                              (intern