emacs-wiki-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emacs-wiki-discuss] MimeTex supports.


From: Yamagata Yoriyuki
Subject: [emacs-wiki-discuss] MimeTex supports.
Date: Sun, 06 Feb 2005 06:07:22 +0900 (JST)

Hi, all.

I have made emacs-wiki-mimetex.el (attached) which supports mimetex in
the Wiki page.  MimeTex is a tool converting TeX-like expressions to
gifs. See http://www.forkosh.com/mimetexmanual.html for more detail.

Using emacs-wiki-mimetex.el, a MimeTeX exporession can be embedded in
a region enclosed by <tex>...</tex>.

You can see an output here.  (Japanese page)
http://www15.ocn.ne.jp/~rodinia/Wiki/FreeSoftwareGameTheory.html

Comparing MathML, MimeTeX has pros and cons such as
Pros:
        1. Do not need MathML supports in browsers.
        2. Do not need MathML fonts in browsers.
        3. Do not need XML (EmacsWiki does not produce correct XML(?))
Cons
        1. It converts TeX to bitmaps (gifs.)
        2. It creates a lot of small files.
        3. It uses gifs (not png, etc)

Comments are welcome.
--
Yamagata Yoriyuki


;;; emacs-wiki-mathml.el --- Provide MathML support for emacs-wiki

;; Copyright (C) 2004 Li Daobing
;; Copyright (C) 2004 Michael Olson
;; Copyright (C) 2005 Yoriyuki Yamagata(山形頼之)

;; This file is not part of GNU Emacs.

;; This is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
;; License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

(require 'emacs-wiki)

(add-to-list 'emacs-wiki-markup-tags
             '("tex" t t t emacs-wiki-mimetex-tag))

(defcustom emacs-wiki-mimetex
  (if (or (featurep 'executable)
          (load "executable" t t))
      (executable-find "mimetex"))
  "Program to use to convert Latex text to gif."
  :type 'string
  :group 'emacs-wiki-publish)

(defcustom emacs-wiki-mimetex-fontsize 2
  "Font size 0-5. The default is 2."
  :type 'integer
  :group 'emacs-wiki-publish)

(setq emacs-wiki-mimetex-counter 0)
(make-variable-buffer-local 'emacs-wiki-mimetex-counter)

(defun emacs-wiki-mimetex-tag (beg end attr highlight-p)
  (if highlight-p
      (goto-char end)
    (if emacs-wiki-mimetex
        (unwind-protect
            (let* ((page (emacs-wiki-page-name (buffer-file-name)))
                   (path (emacs-wiki-published-file page))
                   (body (file-name-sans-extension path))
                   (gif-body (concat body "-mimetex")))
              (if (equal emacs-wiki-mimetex-counter 0)
                  ;; First call in thie buffer
                  (let* ((root (file-name-nondirectory gif-body))
                         (dir (file-name-directory gif-body))
                         (old-gifs (file-name-all-completions root dir)))
                    (mapc (lambda (file) 
                            (delete-file (expand-file-name file dir)))
                          old-gifs)))
              (let*
                    ((gif-name (progn
                                 (setq emacs-wiki-mimetex-counter
                                       (1+ emacs-wiki-mimetex-counter))
                                 (concat gif-body
                                         (number-to-string 
                                          emacs-wiki-mimetex-counter))))
                     (gif-file (concat gif-name ".gif"))
                     (url (file-name-nondirectory gif-file))
                     (tmp-file (make-temp-file "ewiki")))
                  (write-region (point) end tmp-file)
                  (delete-region beg end)
                  (call-process emacs-wiki-mimetex nil "*Messages*" nil
                                "-f" tmp-file "-e" gif-file "s"
                                (number-to-string emacs-wiki-mimetex-fontsize))
                  (insert (format "<img src=\"%s\">" url))
                  (add-text-properties
                   beg (point) '(rear-nonsticky (read-only) read-only t))
                  (delete-file tmp-file)))))))
  
(provide 'emacs-wiki-mimetex)
;;; emacs-wiki-mimetex.el ends here

reply via email to

[Prev in Thread] Current Thread [Next in Thread]