(chise-tex-decode-region): Decode \`, \', \^, \~, \=, \., \" and \d.
[chise/omega.git] / chise2otf / elisp / chise-tex.el
index 3288e19..fc0f13b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; chise-tex.el --- Coding-system based chise2otf like tool
 
-;; Copyright (C) 2004,2005,2006,2007 MORIOKA Tomohiko
+;; Copyright (C) 2004,2005,2006,2007,2008 MORIOKA Tomohiko
 
 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
 ;; Keywords: OTF package, pTeX, CHISE, Multiscript, Multilingual
       (narrow-to-region start end)
       (goto-char start)
       (let (macro code ret me rest spec)
+       (while (re-search-forward "\\\\\\(.\\){\\(.\\)}" nil t)
+         (when (and
+                (setq macro
+                      (assq
+                       (aref (match-string 1) 0)
+                       '((?\` . ?\u0300) ; <COMBINING GRAVE ACCENT>
+                         (?\' . ?\u0301) ; <COMBINING ACUTE ACCENT>
+                         (?^  . ?\u0302) ; <COMBINING CIRCUMFLEX ACCENT>
+                         (?~  . ?\u0303) ; <COMBINING TILDE>
+                         (?=  . ?\u0304) ; <COMBINING MACRON>
+                         (?\. . ?\u0307) ; <COMBINING DOT ABOVE>
+                         (?\" . ?\u0308) ; <COMBINING DIAERESIS>
+                         (?d  . ?\u0323) ; <COMBINING DOT BELOW>
+                         )))
+                (setq ret
+                      (cdr (assq (cdr macro)
+                                 (char-feature (aref (match-string 2) 0)
+                                               'composition)))))
+           (delete-region (match-beginning 0)(match-end 0))
+           (insert ret)))
+       (goto-char start)
        (while (re-search-forward "\\\\\\([a-zA-Z0-9]+\\){\\([0-9A-Fa-f]+\\)}"
                                  nil t)
          (setq macro (match-string 1)