1 ;;; muse-mathml.el --- provide MathML support for Muse
3 ;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
5 ;; Author: Li Daobing (lidaobing AT gmail DOT com)
6 ;; Keywords: Muse mathml hypermedia
8 ;; This file is part of Emacs Muse. It is not part of GNU Emacs.
10 ;; Emacs Muse is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published
12 ;; by the Free Software Foundation; either version 2, or (at your
13 ;; option) any later version.
15 ;; Emacs Muse is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with Emacs Muse; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
29 ;; 1. Get a copy of itex2MML and install it to `/usr/bin' or
32 ;; You can get a copy from
33 ;; `http://pear.math.pitt.edu/mathzilla/itex2mml.tar.gz'.
35 ;; 2. Copy `itex2MML.py' to `/usr/bin' or `/usr/local/bin', if you
36 ;; do not have this file, create it and do a `chmod a+x itex2MML.py'.
37 ;; Its content is the following.
39 ;; #!/usr/bin/env python
40 ;; """A wrap for itex2MML
42 ;; Delete the extra blank line.
44 ;; You can use it as itex2MML.
48 ;; echo '$a_b$' | itex2MML.py
55 ;; fin, fo = os.popen2('itex2MML')
56 ;; fin.write(sys.stdin.read())
59 ;; line = line.strip()
63 ;; if __name__ == '__main__':
66 ;; 3. Put `muse-math.el' into your `load-path'.
68 ;; 4. Add the following to your .emacs file.
70 ;; (require 'muse-mathml)
73 (require 'muse-publish
)
75 (defgroup muse-mathml nil
76 "Options controlling the behavior of Muse XHTML+MathML publishing.
77 See `muse-html' for more information."
80 (defcustom muse-mathml-extension
".xhtml"
81 "Default file extension for publishing XHTML+MathML files."
85 (defcustom muse-mathml-style-sheet muse-xhtml-style-sheet
86 "Store your stylesheet definitions here.
87 This is used in `muse-mathml-header'.
88 You can put raw CSS in here or a <link> tag to an external stylesheet.
89 This text may contain <lisp> markup tags.
91 An example of using <link> is as follows.
93 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/default.css\" />"
97 (defcustom muse-mathml-header
98 "<?xml version=\"1.0\" encoding=\"<lisp>
99 (muse-html-encoding)</lisp>\"?>
100 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN\"
101 \"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd\">
102 <html xmlns=\"http://www.w3.org/1999/xhtml\"
103 xmlns:xlink=\"http://www.w3.org/1999/xlink\">
106 (concat (muse-publishing-directive \"title\")
107 (let ((author (muse-publishing-directive \"author\")))
108 (if (not (string= author (user-full-name)))
109 (concat \" (by \" author \")\"))))</lisp></title>
110 <meta name=\"generator\" content=\"muse.el\" />
111 <meta http-equiv=\"<lisp>muse-html-meta-http-equiv</lisp>\"
112 content=\"<lisp>muse-html-meta-content-type</lisp>\" />
114 (let ((maintainer (muse-style-element :maintainer)))
116 (concat \"<link rev=\\\"made\\\" href=\\\"\" maintainer \"\\\" />\")))
118 <lisp>muse-xhtml-style-sheet</lisp>
122 (concat (muse-publishing-directive \"title\")
123 (let ((author (muse-publishing-directive \"author\")))
124 (if (not (string= author (user-full-name)))
125 (concat \" (by \" author \")\"))))</lisp></h1>
126 <!-- Page published by Emacs Muse begins here -->\n"
127 "Header used for publishing XHTML+MathML files.
128 This may be text or a filename."
132 (defcustom muse-mathml-footer
"
133 <!-- Page published by Emacs Muse ends here -->
136 "Footer used for publishing XHTML+MathML files.
137 This may be text or a filename."
141 (defcustom muse-mathml-command
142 (if (or (featurep 'executable
)
143 (load "executable" t t
))
144 (executable-find "itex2MML.py"))
145 "Program to use to convert Latex text to MathML."
149 (defun muse-publish-mathml-tag (beg end
)
150 (if muse-mathml-command
151 (muse-publish-command-tag
152 beg end
(list (cons "interp" muse-mathml-command
)))
153 (muse-publish-example-tag beg end
)))
155 ;; Add the <mathml> tag
157 (add-to-list 'muse-publish-markup-tags
158 '("mathml" t nil muse-publish-mathml-tag
)
161 ;; Register the Muse MathML Publisher
163 (muse-derive-style "mathml" "xhtml"
164 :suffix
'muse-mathml-extension
165 :header
'muse-mathml-header
166 :footer
'muse-mathml-footer
)
168 (provide 'muse-mathml
)
169 ;;; muse-mathml.el ends here