mizuho 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.markdown +61 -0
- data/Rakefile +41 -0
- data/asciidoc/BUGS +39 -0
- data/asciidoc/BUGS.txt +32 -0
- data/asciidoc/CHANGELOG +1796 -0
- data/asciidoc/CHANGELOG.txt +1810 -0
- data/asciidoc/COPYING +339 -0
- data/asciidoc/COPYRIGHT +18 -0
- data/asciidoc/INSTALL +76 -0
- data/asciidoc/INSTALL.txt +71 -0
- data/asciidoc/Makefile.in +161 -0
- data/asciidoc/README +46 -0
- data/asciidoc/README.txt +36 -0
- data/asciidoc/a2x +674 -0
- data/asciidoc/asciidoc.conf +455 -0
- data/asciidoc/asciidoc.py +4998 -0
- data/asciidoc/common.aap +9 -0
- data/asciidoc/configure +2840 -0
- data/asciidoc/configure.ac +11 -0
- data/asciidoc/dblatex/asciidoc-dblatex.sty +20 -0
- data/asciidoc/dblatex/asciidoc-dblatex.xsl +32 -0
- data/asciidoc/dblatex/dblatex-readme.txt +39 -0
- data/asciidoc/doc/a2x.1 +257 -0
- data/asciidoc/doc/a2x.1.txt +204 -0
- data/asciidoc/doc/article.css-embedded.html +602 -0
- data/asciidoc/doc/article.html +46 -0
- data/asciidoc/doc/article.pdf +0 -0
- data/asciidoc/doc/article.txt +122 -0
- data/asciidoc/doc/asciidoc-revhistory.xml +27 -0
- data/asciidoc/doc/asciidoc.1 +155 -0
- data/asciidoc/doc/asciidoc.1.css-embedded.html +598 -0
- data/asciidoc/doc/asciidoc.1.css.html +212 -0
- data/asciidoc/doc/asciidoc.1.html +190 -0
- data/asciidoc/doc/asciidoc.1.txt +118 -0
- data/asciidoc/doc/asciidoc.conf +8 -0
- data/asciidoc/doc/asciidoc.css-embedded.html +7853 -0
- data/asciidoc/doc/asciidoc.css.html +7416 -0
- data/asciidoc/doc/asciidoc.dict +733 -0
- data/asciidoc/doc/asciidoc.html +3339 -0
- data/asciidoc/doc/asciidoc.txt +4979 -0
- data/asciidoc/doc/asciimathml.txt +64 -0
- data/asciidoc/doc/book-multi.css-embedded.html +575 -0
- data/asciidoc/doc/book-multi.html +55 -0
- data/asciidoc/doc/book-multi.txt +155 -0
- data/asciidoc/doc/book.css-embedded.html +607 -0
- data/asciidoc/doc/book.html +43 -0
- data/asciidoc/doc/book.txt +131 -0
- data/asciidoc/doc/customers.csv +18 -0
- data/asciidoc/doc/docbook-xsl.css +272 -0
- data/asciidoc/doc/faq.txt +547 -0
- data/asciidoc/doc/latex-backend.html +117 -0
- data/asciidoc/doc/latex-backend.txt +191 -0
- data/asciidoc/doc/latexmath.txt +244 -0
- data/asciidoc/doc/latexmathml.txt +41 -0
- data/asciidoc/doc/main.aap +297 -0
- data/asciidoc/doc/music-filter.html +566 -0
- data/asciidoc/doc/music-filter.pdf +0 -0
- data/asciidoc/doc/music-filter.txt +158 -0
- data/asciidoc/doc/source-highlight-filter.html +214 -0
- data/asciidoc/doc/source-highlight-filter.pdf +0 -0
- data/asciidoc/doc/source-highlight-filter.txt +203 -0
- data/asciidoc/docbook-xsl/asciidoc-docbook-xsl.txt +43 -0
- data/asciidoc/docbook-xsl/chunked.xsl +19 -0
- data/asciidoc/docbook-xsl/common.xsl +67 -0
- data/asciidoc/docbook-xsl/fo.xsl +149 -0
- data/asciidoc/docbook-xsl/htmlhelp.xsl +17 -0
- data/asciidoc/docbook-xsl/manpage.xsl +31 -0
- data/asciidoc/docbook-xsl/text.xsl +50 -0
- data/asciidoc/docbook-xsl/xhtml.xsl +14 -0
- data/asciidoc/docbook.conf +721 -0
- data/asciidoc/examples/website/ASCIIMathML.js +938 -0
- data/asciidoc/examples/website/CHANGELOG.html +4389 -0
- data/asciidoc/examples/website/CHANGELOG.txt +1810 -0
- data/asciidoc/examples/website/INSTALL.html +161 -0
- data/asciidoc/examples/website/INSTALL.txt +71 -0
- data/asciidoc/examples/website/LaTeXMathML.js +1223 -0
- data/asciidoc/examples/website/README-website.html +118 -0
- data/asciidoc/examples/website/README-website.txt +29 -0
- data/asciidoc/examples/website/README.html +125 -0
- data/asciidoc/examples/website/README.txt +36 -0
- data/asciidoc/examples/website/a2x.1.html +419 -0
- data/asciidoc/examples/website/a2x.1.txt +204 -0
- data/asciidoc/examples/website/asciidoc-docbook-xsl.html +130 -0
- data/asciidoc/examples/website/asciidoc-docbook-xsl.txt +43 -0
- data/asciidoc/examples/website/asciidoc-graphviz-sample.txt +130 -0
- data/asciidoc/examples/website/asciimathml.txt +64 -0
- data/asciidoc/examples/website/build-website.sh +25 -0
- data/asciidoc/examples/website/customers.csv +18 -0
- data/asciidoc/examples/website/downloads.html +257 -0
- data/asciidoc/examples/website/downloads.txt +121 -0
- data/asciidoc/examples/website/faq.html +673 -0
- data/asciidoc/examples/website/faq.txt +547 -0
- data/asciidoc/examples/website/index.html +419 -0
- data/asciidoc/examples/website/index.txt +245 -0
- data/asciidoc/examples/website/latex-backend.html +535 -0
- data/asciidoc/examples/website/latex-backend.txt +191 -0
- data/asciidoc/examples/website/latexmathml.txt +41 -0
- data/asciidoc/examples/website/layout1.conf +161 -0
- data/asciidoc/examples/website/layout1.css +65 -0
- data/asciidoc/examples/website/layout2.conf +158 -0
- data/asciidoc/examples/website/layout2.css +93 -0
- data/asciidoc/examples/website/manpage.html +266 -0
- data/asciidoc/examples/website/manpage.txt +118 -0
- data/asciidoc/examples/website/music-filter.html +242 -0
- data/asciidoc/examples/website/music-filter.txt +158 -0
- data/asciidoc/examples/website/music1.abc +12 -0
- data/asciidoc/examples/website/music1.png +0 -0
- data/asciidoc/examples/website/music2.ly +9 -0
- data/asciidoc/examples/website/music2.png +0 -0
- data/asciidoc/examples/website/newlists.txt +40 -0
- data/asciidoc/examples/website/newtables.txt +397 -0
- data/asciidoc/examples/website/sample1.png +0 -0
- data/asciidoc/examples/website/sample3.png +0 -0
- data/asciidoc/examples/website/sample4.png +0 -0
- data/asciidoc/examples/website/source-highlight-filter.html +286 -0
- data/asciidoc/examples/website/source-highlight-filter.txt +203 -0
- data/asciidoc/examples/website/support.html +78 -0
- data/asciidoc/examples/website/support.txt +5 -0
- data/asciidoc/examples/website/toc.js +69 -0
- data/asciidoc/examples/website/userguide.html +7460 -0
- data/asciidoc/examples/website/userguide.txt +4979 -0
- data/asciidoc/examples/website/version83.txt +37 -0
- data/asciidoc/examples/website/version9.html +143 -0
- data/asciidoc/examples/website/version9.txt +48 -0
- data/asciidoc/examples/website/xhtml11-manpage.css +18 -0
- data/asciidoc/examples/website/xhtml11-quirks.css +41 -0
- data/asciidoc/examples/website/xhtml11.css +328 -0
- data/asciidoc/filters/code/code-filter-readme.txt +37 -0
- data/asciidoc/filters/code/code-filter-test.txt +15 -0
- data/asciidoc/filters/code/code-filter.conf +8 -0
- data/asciidoc/filters/code/code-filter.py +239 -0
- data/asciidoc/filters/graphviz/asciidoc-graphviz-sample.txt +130 -0
- data/asciidoc/filters/graphviz/graphviz-filter.conf +39 -0
- data/asciidoc/filters/graphviz/graphviz2png.py +154 -0
- data/asciidoc/filters/music/music-filter-test.txt +40 -0
- data/asciidoc/filters/music/music-filter.conf +40 -0
- data/asciidoc/filters/music/music2png.py +189 -0
- data/asciidoc/filters/source/source-highlight-filter-test.txt +19 -0
- data/asciidoc/filters/source/source-highlight-filter.conf +108 -0
- data/asciidoc/help.conf +213 -0
- data/asciidoc/html4.conf +460 -0
- data/asciidoc/images/highlighter.png +0 -0
- data/asciidoc/images/icons/README +5 -0
- data/asciidoc/images/icons/callouts/1.png +0 -0
- data/asciidoc/images/icons/callouts/10.png +0 -0
- data/asciidoc/images/icons/callouts/11.png +0 -0
- data/asciidoc/images/icons/callouts/12.png +0 -0
- data/asciidoc/images/icons/callouts/13.png +0 -0
- data/asciidoc/images/icons/callouts/14.png +0 -0
- data/asciidoc/images/icons/callouts/15.png +0 -0
- data/asciidoc/images/icons/callouts/2.png +0 -0
- data/asciidoc/images/icons/callouts/3.png +0 -0
- data/asciidoc/images/icons/callouts/4.png +0 -0
- data/asciidoc/images/icons/callouts/5.png +0 -0
- data/asciidoc/images/icons/callouts/6.png +0 -0
- data/asciidoc/images/icons/callouts/7.png +0 -0
- data/asciidoc/images/icons/callouts/8.png +0 -0
- data/asciidoc/images/icons/callouts/9.png +0 -0
- data/asciidoc/images/icons/caution.png +0 -0
- data/asciidoc/images/icons/example.png +0 -0
- data/asciidoc/images/icons/home.png +0 -0
- data/asciidoc/images/icons/important.png +0 -0
- data/asciidoc/images/icons/next.png +0 -0
- data/asciidoc/images/icons/note.png +0 -0
- data/asciidoc/images/icons/prev.png +0 -0
- data/asciidoc/images/icons/tip.png +0 -0
- data/asciidoc/images/icons/up.png +0 -0
- data/asciidoc/images/icons/warning.png +0 -0
- data/asciidoc/images/smallnew.png +0 -0
- data/asciidoc/images/tiger.png +0 -0
- data/asciidoc/install-sh +201 -0
- data/asciidoc/javascripts/ASCIIMathML.js +938 -0
- data/asciidoc/javascripts/LaTeXMathML.js +1223 -0
- data/asciidoc/javascripts/toc.js +69 -0
- data/asciidoc/lang-es.conf +15 -0
- data/asciidoc/latex.conf +663 -0
- data/asciidoc/stylesheets/docbook-xsl.css +272 -0
- data/asciidoc/stylesheets/xhtml11-manpage.css +18 -0
- data/asciidoc/stylesheets/xhtml11-quirks.css +41 -0
- data/asciidoc/stylesheets/xhtml11.css +328 -0
- data/asciidoc/text.conf +16 -0
- data/asciidoc/vim/ftdetect/asciidoc_filetype.vim +53 -0
- data/asciidoc/vim/syntax/asciidoc.vim +165 -0
- data/asciidoc/wordpress.conf +48 -0
- data/asciidoc/xhtml11-quirks.conf +57 -0
- data/asciidoc/xhtml11.conf +645 -0
- data/bin/mizuho +47 -0
- data/bin/mizuho-asciidoc +4 -0
- data/lib/mizuho.rb +10 -0
- data/lib/mizuho/chapter.rb +54 -0
- data/lib/mizuho/generator.rb +134 -0
- data/lib/mizuho/heading.rb +46 -0
- data/lib/mizuho/parser.rb +103 -0
- data/lib/mizuho/source_highlight.rb +2 -0
- data/lib/mizuho/template.rb +50 -0
- data/source-highlight/ada.lang +38 -0
- data/source-highlight/bib.lang +6 -0
- data/source-highlight/bison.lang +3 -0
- data/source-highlight/c.lang +41 -0
- data/source-highlight/c_comment.lang +27 -0
- data/source-highlight/c_string.lang +9 -0
- data/source-highlight/caml.lang +16 -0
- data/source-highlight/changelog.lang +8 -0
- data/source-highlight/clike_vardeclaration.lang +4 -0
- data/source-highlight/cpp.lang +15 -0
- data/source-highlight/csharp.lang +36 -0
- data/source-highlight/css.lang +14 -0
- data/source-highlight/css_common.outlang +26 -0
- data/source-highlight/darwin/source-highlight +0 -0
- data/source-highlight/default.css +51 -0
- data/source-highlight/default.lang +8 -0
- data/source-highlight/default.style +57 -0
- data/source-highlight/desktop.lang +7 -0
- data/source-highlight/diff.lang +32 -0
- data/source-highlight/docbook.outlang +36 -0
- data/source-highlight/esc.outlang +46 -0
- data/source-highlight/esc.style +35 -0
- data/source-highlight/extreme_comment.lang +5 -0
- data/source-highlight/extreme_comment2.lang +5 -0
- data/source-highlight/extreme_comment3.lang +15 -0
- data/source-highlight/fixed-fortran.lang +5 -0
- data/source-highlight/flex.lang +37 -0
- data/source-highlight/fortran.lang +57 -0
- data/source-highlight/function.lang +2 -0
- data/source-highlight/glsl.lang +86 -0
- data/source-highlight/haxe.lang +7 -0
- data/source-highlight/html.lang +7 -0
- data/source-highlight/html.outlang +25 -0
- data/source-highlight/html_common.outlang +35 -0
- data/source-highlight/html_notfixed.outlang +22 -0
- data/source-highlight/html_ref.outlang +6 -0
- data/source-highlight/htmlcss.outlang +28 -0
- data/source-highlight/htmltable.outlang +14 -0
- data/source-highlight/htmltablelinenum.outlang +26 -0
- data/source-highlight/java.lang +26 -0
- data/source-highlight/javadoc.outlang +24 -0
- data/source-highlight/javascript.lang +27 -0
- data/source-highlight/key_string.lang +4 -0
- data/source-highlight/lang.map +108 -0
- data/source-highlight/langdef.lang +21 -0
- data/source-highlight/latex.lang +52 -0
- data/source-highlight/latex.outlang +59 -0
- data/source-highlight/latexcolor.outlang +44 -0
- data/source-highlight/ldap.lang +10 -0
- data/source-highlight/log.lang +53 -0
- data/source-highlight/logtalk.lang +85 -0
- data/source-highlight/lsm.lang +7 -0
- data/source-highlight/lua.lang +27 -0
- data/source-highlight/m4.lang +27 -0
- data/source-highlight/makefile.lang +42 -0
- data/source-highlight/nohilite.lang +2 -0
- data/source-highlight/number.lang +3 -0
- data/source-highlight/outlang.lang +16 -0
- data/source-highlight/outlang.map +12 -0
- data/source-highlight/pascal.lang +20 -0
- data/source-highlight/perl.lang +134 -0
- data/source-highlight/php.lang +25 -0
- data/source-highlight/postscript.lang +42 -0
- data/source-highlight/prolog.lang +37 -0
- data/source-highlight/properties.lang +7 -0
- data/source-highlight/python.lang +26 -0
- data/source-highlight/ruby.lang +32 -0
- data/source-highlight/scala.lang +31 -0
- data/source-highlight/script_comment.lang +3 -0
- data/source-highlight/sh.lang +38 -0
- data/source-highlight/slang.lang +25 -0
- data/source-highlight/sml.lang +5 -0
- data/source-highlight/source-highlight +24 -0
- data/source-highlight/spec.lang +12 -0
- data/source-highlight/sql.lang +46 -0
- data/source-highlight/style.defaults +15 -0
- data/source-highlight/style.lang +16 -0
- data/source-highlight/style2.style +10 -0
- data/source-highlight/style3.style +10 -0
- data/source-highlight/symbols.lang +2 -0
- data/source-highlight/tcl.lang +35 -0
- data/source-highlight/texinfo.outlang +34 -0
- data/source-highlight/texinfo.style +20 -0
- data/source-highlight/url.lang +3 -0
- data/source-highlight/xhtml.outlang +25 -0
- data/source-highlight/xhtml_common.outlang +8 -0
- data/source-highlight/xhtml_notfixed.outlang +16 -0
- data/source-highlight/xhtmlcss.outlang +19 -0
- data/source-highlight/xhtmltable.outlang +7 -0
- data/source-highlight/xml.lang +17 -0
- data/source-highlight/xorg.lang +10 -0
- data/templates/asciidoc.css +358 -0
- data/templates/asciidoc.html.erb +86 -0
- data/templates/manualsonrails.css +165 -0
- data/templates/manualsonrails.html.erb +97 -0
- data/test/generator_spec.rb +60 -0
- data/test/parser_spec.rb +239 -0
- data/test/spec_helper.rb +51 -0
- metadata +358 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/asciidoc/install-sh
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# install - install a program, script, or datafile
|
4
|
+
# This comes from X11R5 (mit/util/scripts/install.sh).
|
5
|
+
#
|
6
|
+
# Copyright 1991 by the Massachusetts Institute of Technology
|
7
|
+
#
|
8
|
+
# Permission to use, copy, modify, distribute, and sell this software and its
|
9
|
+
# documentation for any purpose is hereby granted without fee, provided that
|
10
|
+
# the above copyright notice appear in all copies and that both that
|
11
|
+
# copyright notice and this permission notice appear in supporting
|
12
|
+
# documentation, and that the name of M.I.T. not be used in advertising or
|
13
|
+
# publicity pertaining to distribution of the software without specific,
|
14
|
+
# written prior permission. M.I.T. makes no representations about the
|
15
|
+
# suitability of this software for any purpose. It is provided "as is"
|
16
|
+
# without express or implied warranty.
|
17
|
+
#
|
18
|
+
# Calling this script install-sh is preferred over install.sh, to prevent
|
19
|
+
# `make' implicit rules from creating a file called install from it
|
20
|
+
# when there is no Makefile.
|
21
|
+
#
|
22
|
+
# This script is compatible with the BSD install script, but was written
|
23
|
+
# from scratch. It can only install one file at a time, a restriction
|
24
|
+
# shared with many OS's install programs.
|
25
|
+
# set DOITPROG to echo to test this script
|
26
|
+
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
27
|
+
doit="${DOITPROG-}"
|
28
|
+
# put in absolute paths if you don't have them in your path; or use env. vars.
|
29
|
+
mvprog="${MVPROG-mv}"
|
30
|
+
cpprog="${CPPROG-cp}"
|
31
|
+
chmodprog="${CHMODPROG-chmod}"
|
32
|
+
chownprog="${CHOWNPROG-chown}"
|
33
|
+
chgrpprog="${CHGRPPROG-chgrp}"
|
34
|
+
stripprog="${STRIPPROG-strip}"
|
35
|
+
rmprog="${RMPROG-rm}"
|
36
|
+
mkdirprog="${MKDIRPROG-mkdir}"
|
37
|
+
transformbasename=""
|
38
|
+
transform_arg=""
|
39
|
+
instcmd="$mvprog"
|
40
|
+
chmodcmd="$chmodprog 0755"
|
41
|
+
chowncmd=""
|
42
|
+
chgrpcmd=""
|
43
|
+
stripcmd=""
|
44
|
+
rmcmd="$rmprog -f"
|
45
|
+
mvcmd="$mvprog"
|
46
|
+
src=""
|
47
|
+
dst=""
|
48
|
+
dir_arg=""
|
49
|
+
while [ x"$1" != x ]; do
|
50
|
+
case $1 in
|
51
|
+
-c) instcmd="$cpprog"
|
52
|
+
shift
|
53
|
+
continue;;
|
54
|
+
-d) dir_arg=true
|
55
|
+
shift
|
56
|
+
continue;;
|
57
|
+
-m) chmodcmd="$chmodprog $2"
|
58
|
+
shift
|
59
|
+
shift
|
60
|
+
continue;;
|
61
|
+
-o) chowncmd="$chownprog $2"
|
62
|
+
shift
|
63
|
+
shift
|
64
|
+
continue;;
|
65
|
+
-g) chgrpcmd="$chgrpprog $2"
|
66
|
+
shift
|
67
|
+
shift
|
68
|
+
continue;;
|
69
|
+
-s) stripcmd="$stripprog"
|
70
|
+
shift
|
71
|
+
continue;;
|
72
|
+
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
73
|
+
shift
|
74
|
+
continue;;
|
75
|
+
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
76
|
+
shift
|
77
|
+
continue;;
|
78
|
+
*) if [ x"$src" = x ]
|
79
|
+
then
|
80
|
+
src=$1
|
81
|
+
else
|
82
|
+
# this colon is to work around a 386BSD /bin/sh bug
|
83
|
+
:
|
84
|
+
dst=$1
|
85
|
+
fi
|
86
|
+
shift
|
87
|
+
continue;;
|
88
|
+
esac
|
89
|
+
done
|
90
|
+
if [ x"$src" = x ]
|
91
|
+
then
|
92
|
+
echo "install: no input file specified"
|
93
|
+
exit 1
|
94
|
+
else
|
95
|
+
true
|
96
|
+
fi
|
97
|
+
if [ x"$dir_arg" != x ]; then
|
98
|
+
dst=$src
|
99
|
+
src=""
|
100
|
+
|
101
|
+
if [ -d $dst ]; then
|
102
|
+
instcmd=:
|
103
|
+
else
|
104
|
+
instcmd=mkdir
|
105
|
+
fi
|
106
|
+
else
|
107
|
+
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
108
|
+
# might cause directories to be created, which would be especially bad
|
109
|
+
# if $src (and thus $dsttmp) contains '*'.
|
110
|
+
if [ -f $src -o -d $src ]
|
111
|
+
then
|
112
|
+
true
|
113
|
+
else
|
114
|
+
echo "install: $src does not exist"
|
115
|
+
exit 1
|
116
|
+
fi
|
117
|
+
|
118
|
+
if [ x"$dst" = x ]
|
119
|
+
then
|
120
|
+
echo "install: no destination specified"
|
121
|
+
exit 1
|
122
|
+
else
|
123
|
+
true
|
124
|
+
fi
|
125
|
+
# If destination is a directory, append the input filename; if your system
|
126
|
+
# does not like double slashes in filenames, you may need to add some logic
|
127
|
+
if [ -d $dst ]
|
128
|
+
then
|
129
|
+
dst="$dst"/`basename $src`
|
130
|
+
else
|
131
|
+
true
|
132
|
+
fi
|
133
|
+
fi
|
134
|
+
## this sed command emulates the dirname command
|
135
|
+
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
136
|
+
# Make sure that the destination directory exists.
|
137
|
+
# this part is taken from Noah Friedman's mkinstalldirs script
|
138
|
+
# Skip lots of stat calls in the usual case.
|
139
|
+
if [ ! -d "$dstdir" ]; then
|
140
|
+
defaultIFS='
|
141
|
+
'
|
142
|
+
IFS="${IFS-${defaultIFS}}"
|
143
|
+
oIFS="${IFS}"
|
144
|
+
# Some sh's can't handle IFS=/ for some reason.
|
145
|
+
IFS='%'
|
146
|
+
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
147
|
+
IFS="${oIFS}"
|
148
|
+
pathcomp=''
|
149
|
+
while [ $# -ne 0 ] ; do
|
150
|
+
pathcomp="${pathcomp}${1}"
|
151
|
+
shift
|
152
|
+
if [ ! -d "${pathcomp}" ] ;
|
153
|
+
then
|
154
|
+
$mkdirprog "${pathcomp}"
|
155
|
+
else
|
156
|
+
true
|
157
|
+
fi
|
158
|
+
pathcomp="${pathcomp}/"
|
159
|
+
done
|
160
|
+
fi
|
161
|
+
if [ x"$dir_arg" != x ]
|
162
|
+
then
|
163
|
+
$doit $instcmd $dst &&
|
164
|
+
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
165
|
+
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
166
|
+
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
167
|
+
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
168
|
+
else
|
169
|
+
# If we're going to rename the final executable, determine the name now.
|
170
|
+
if [ x"$transformarg" = x ]
|
171
|
+
then
|
172
|
+
dstfile=`basename $dst`
|
173
|
+
else
|
174
|
+
dstfile=`basename $dst $transformbasename |
|
175
|
+
sed $transformarg`$transformbasename
|
176
|
+
fi
|
177
|
+
# don't allow the sed command to completely eliminate the filename
|
178
|
+
if [ x"$dstfile" = x ]
|
179
|
+
then
|
180
|
+
dstfile=`basename $dst`
|
181
|
+
else
|
182
|
+
true
|
183
|
+
fi
|
184
|
+
# Make a temp file name in the proper directory.
|
185
|
+
dsttmp=$dstdir/#inst.$$#
|
186
|
+
# Move or copy the file name to the temp name
|
187
|
+
$doit $instcmd $src $dsttmp &&
|
188
|
+
trap "rm -f ${dsttmp}" 0 &&
|
189
|
+
# and set any options; do chmod last to preserve setuid bits
|
190
|
+
# If any of these fail, we abort the whole thing. If we want to
|
191
|
+
# ignore errors from any of these, just make sure not to ignore
|
192
|
+
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
193
|
+
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
194
|
+
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
195
|
+
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
196
|
+
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
197
|
+
# Now rename the file to the real destination.
|
198
|
+
$doit $rmcmd -f $dstdir/$dstfile &&
|
199
|
+
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
200
|
+
fi &&
|
201
|
+
exit 0
|
@@ -0,0 +1,938 @@
|
|
1
|
+
/*
|
2
|
+
ASCIIMathML.js
|
3
|
+
==============
|
4
|
+
This file contains JavaScript functions to convert ASCII math notation
|
5
|
+
to Presentation MathML. The conversion is done while the (X)HTML page
|
6
|
+
loads, and should work with Firefox/Mozilla/Netscape 7+ and Internet
|
7
|
+
Explorer 6+MathPlayer (http://www.dessci.com/en/products/mathplayer/).
|
8
|
+
Just add the next line to your (X)HTML page with this file in the same folder:
|
9
|
+
This is a convenient and inexpensive solution for authoring MathML.
|
10
|
+
|
11
|
+
Version 1.4.7 Dec 15, 2005, (c) Peter Jipsen http://www.chapman.edu/~jipsen
|
12
|
+
Latest version at http://www.chapman.edu/~jipsen/mathml/ASCIIMathML.js
|
13
|
+
For changes see http://www.chapman.edu/~jipsen/mathml/asciimathchanges.txt
|
14
|
+
If you use it on a webpage, please send the URL to jipsen@chapman.edu
|
15
|
+
|
16
|
+
This program is free software; you can redistribute it and/or modify
|
17
|
+
it under the terms of the GNU General Public License as published by
|
18
|
+
the Free Software Foundation; either version 2 of the License, or (at
|
19
|
+
your option) any later version.
|
20
|
+
|
21
|
+
This program is distributed in the hope that it will be useful,
|
22
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
24
|
+
General Public License (at http://www.gnu.org/copyleft/gpl.html)
|
25
|
+
for more details.
|
26
|
+
*/
|
27
|
+
|
28
|
+
var checkForMathML = true; // check if browser can display MathML
|
29
|
+
var notifyIfNoMathML = true; // display note if no MathML capability
|
30
|
+
var alertIfNoMathML = false; // show alert box if no MathML capability
|
31
|
+
var mathcolor = ""; // change it to "" (to inherit) or any other color
|
32
|
+
var mathfontfamily = "serif"; // change to "" to inherit (works in IE)
|
33
|
+
// or another family (e.g. "arial")
|
34
|
+
var displaystyle = true; // puts limits above and below large operators
|
35
|
+
var showasciiformulaonhover = true; // helps students learn ASCIIMath
|
36
|
+
var decimalsign = "."; // change to "," if you like, beware of `(1,2)`!
|
37
|
+
var AMdelimiter1 = "`", AMescape1 = "\\\\`"; // can use other characters
|
38
|
+
var AMdelimiter2 = "$", AMescape2 = "\\\\\\$", AMdelimiter2regexp = "\\$";
|
39
|
+
var doubleblankmathdelimiter = false; // if true, x+1 is equal to `x+1`
|
40
|
+
// for IE this works only in <!-- -->
|
41
|
+
//var separatetokens;// has been removed (email me if this is a problem)
|
42
|
+
var isIE = document.createElementNS==null;
|
43
|
+
|
44
|
+
if (document.getElementById==null)
|
45
|
+
alert("This webpage requires a recent browser such as\
|
46
|
+
\nMozilla/Netscape 7+ or Internet Explorer 6+MathPlayer")
|
47
|
+
|
48
|
+
// all further global variables start with "AM"
|
49
|
+
|
50
|
+
function AMcreateElementXHTML(t) {
|
51
|
+
if (isIE) return document.createElement(t);
|
52
|
+
else return document.createElementNS("http://www.w3.org/1999/xhtml",t);
|
53
|
+
}
|
54
|
+
|
55
|
+
function AMnoMathMLNote() {
|
56
|
+
var nd = AMcreateElementXHTML("h3");
|
57
|
+
nd.setAttribute("align","center")
|
58
|
+
nd.appendChild(AMcreateElementXHTML("p"));
|
59
|
+
nd.appendChild(document.createTextNode("To view the "));
|
60
|
+
var an = AMcreateElementXHTML("a");
|
61
|
+
an.appendChild(document.createTextNode("ASCIIMathML"));
|
62
|
+
an.setAttribute("href","http://www.chapman.edu/~jipsen/asciimath.html");
|
63
|
+
nd.appendChild(an);
|
64
|
+
nd.appendChild(document.createTextNode(" notation use Internet Explorer 6+"));
|
65
|
+
an = AMcreateElementXHTML("a");
|
66
|
+
an.appendChild(document.createTextNode("MathPlayer"));
|
67
|
+
an.setAttribute("href","http://www.dessci.com/en/products/mathplayer/download.htm");
|
68
|
+
nd.appendChild(an);
|
69
|
+
nd.appendChild(document.createTextNode(" or Netscape/Mozilla/Firefox"));
|
70
|
+
nd.appendChild(AMcreateElementXHTML("p"));
|
71
|
+
return nd;
|
72
|
+
}
|
73
|
+
|
74
|
+
function AMisMathMLavailable() {
|
75
|
+
if (navigator.appName.slice(0,8)=="Netscape")
|
76
|
+
if (navigator.appVersion.slice(0,1)>="5") return null;
|
77
|
+
else return AMnoMathMLNote();
|
78
|
+
else if (navigator.appName.slice(0,9)=="Microsoft")
|
79
|
+
try {
|
80
|
+
var ActiveX = new ActiveXObject("MathPlayer.Factory.1");
|
81
|
+
return null;
|
82
|
+
} catch (e) {
|
83
|
+
return AMnoMathMLNote();
|
84
|
+
}
|
85
|
+
else return AMnoMathMLNote();
|
86
|
+
}
|
87
|
+
|
88
|
+
// character lists for Mozilla/Netscape fonts
|
89
|
+
var AMcal = [0xEF35,0x212C,0xEF36,0xEF37,0x2130,0x2131,0xEF38,0x210B,0x2110,0xEF39,0xEF3A,0x2112,0x2133,0xEF3B,0xEF3C,0xEF3D,0xEF3E,0x211B,0xEF3F,0xEF40,0xEF41,0xEF42,0xEF43,0xEF44,0xEF45,0xEF46];
|
90
|
+
var AMfrk = [0xEF5D,0xEF5E,0x212D,0xEF5F,0xEF60,0xEF61,0xEF62,0x210C,0x2111,0xEF63,0xEF64,0xEF65,0xEF66,0xEF67,0xEF68,0xEF69,0xEF6A,0x211C,0xEF6B,0xEF6C,0xEF6D,0xEF6E,0xEF6F,0xEF70,0xEF71,0x2128];
|
91
|
+
var AMbbb = [0xEF8C,0xEF8D,0x2102,0xEF8E,0xEF8F,0xEF90,0xEF91,0x210D,0xEF92,0xEF93,0xEF94,0xEF95,0xEF96,0x2115,0xEF97,0x2119,0x211A,0x211D,0xEF98,0xEF99,0xEF9A,0xEF9B,0xEF9C,0xEF9D,0xEF9E,0x2124];
|
92
|
+
|
93
|
+
var CONST = 0, UNARY = 1, BINARY = 2, INFIX = 3, LEFTBRACKET = 4,
|
94
|
+
RIGHTBRACKET = 5, SPACE = 6, UNDEROVER = 7, DEFINITION = 8,
|
95
|
+
LEFTRIGHT = 9, TEXT = 10; // token types
|
96
|
+
|
97
|
+
var AMsqrt = {input:"sqrt", tag:"msqrt", output:"sqrt", tex:null, ttype:UNARY},
|
98
|
+
AMroot = {input:"root", tag:"mroot", output:"root", tex:null, ttype:BINARY},
|
99
|
+
AMfrac = {input:"frac", tag:"mfrac", output:"/", tex:null, ttype:BINARY},
|
100
|
+
AMdiv = {input:"/", tag:"mfrac", output:"/", tex:null, ttype:INFIX},
|
101
|
+
AMover = {input:"stackrel", tag:"mover", output:"stackrel", tex:null, ttype:BINARY},
|
102
|
+
AMsub = {input:"_", tag:"msub", output:"_", tex:null, ttype:INFIX},
|
103
|
+
AMsup = {input:"^", tag:"msup", output:"^", tex:null, ttype:INFIX},
|
104
|
+
AMtext = {input:"text", tag:"mtext", output:"text", tex:null, ttype:TEXT},
|
105
|
+
AMmbox = {input:"mbox", tag:"mtext", output:"mbox", tex:null, ttype:TEXT},
|
106
|
+
AMquote = {input:"\"", tag:"mtext", output:"mbox", tex:null, ttype:TEXT};
|
107
|
+
|
108
|
+
var AMsymbols = [
|
109
|
+
//some greek symbols
|
110
|
+
{input:"alpha", tag:"mi", output:"\u03B1", tex:null, ttype:CONST},
|
111
|
+
{input:"beta", tag:"mi", output:"\u03B2", tex:null, ttype:CONST},
|
112
|
+
{input:"chi", tag:"mi", output:"\u03C7", tex:null, ttype:CONST},
|
113
|
+
{input:"delta", tag:"mi", output:"\u03B4", tex:null, ttype:CONST},
|
114
|
+
{input:"Delta", tag:"mo", output:"\u0394", tex:null, ttype:CONST},
|
115
|
+
{input:"epsi", tag:"mi", output:"\u03B5", tex:"epsilon", ttype:CONST},
|
116
|
+
{input:"varepsilon", tag:"mi", output:"\u025B", tex:null, ttype:CONST},
|
117
|
+
{input:"eta", tag:"mi", output:"\u03B7", tex:null, ttype:CONST},
|
118
|
+
{input:"gamma", tag:"mi", output:"\u03B3", tex:null, ttype:CONST},
|
119
|
+
{input:"Gamma", tag:"mo", output:"\u0393", tex:null, ttype:CONST},
|
120
|
+
{input:"iota", tag:"mi", output:"\u03B9", tex:null, ttype:CONST},
|
121
|
+
{input:"kappa", tag:"mi", output:"\u03BA", tex:null, ttype:CONST},
|
122
|
+
{input:"lambda", tag:"mi", output:"\u03BB", tex:null, ttype:CONST},
|
123
|
+
{input:"Lambda", tag:"mo", output:"\u039B", tex:null, ttype:CONST},
|
124
|
+
{input:"mu", tag:"mi", output:"\u03BC", tex:null, ttype:CONST},
|
125
|
+
{input:"nu", tag:"mi", output:"\u03BD", tex:null, ttype:CONST},
|
126
|
+
{input:"omega", tag:"mi", output:"\u03C9", tex:null, ttype:CONST},
|
127
|
+
{input:"Omega", tag:"mo", output:"\u03A9", tex:null, ttype:CONST},
|
128
|
+
{input:"phi", tag:"mi", output:"\u03C6", tex:null, ttype:CONST},
|
129
|
+
{input:"varphi", tag:"mi", output:"\u03D5", tex:null, ttype:CONST},
|
130
|
+
{input:"Phi", tag:"mo", output:"\u03A6", tex:null, ttype:CONST},
|
131
|
+
{input:"pi", tag:"mi", output:"\u03C0", tex:null, ttype:CONST},
|
132
|
+
{input:"Pi", tag:"mo", output:"\u03A0", tex:null, ttype:CONST},
|
133
|
+
{input:"psi", tag:"mi", output:"\u03C8", tex:null, ttype:CONST},
|
134
|
+
{input:"Psi", tag:"mi", output:"\u03A8", tex:null, ttype:CONST},
|
135
|
+
{input:"rho", tag:"mi", output:"\u03C1", tex:null, ttype:CONST},
|
136
|
+
{input:"sigma", tag:"mi", output:"\u03C3", tex:null, ttype:CONST},
|
137
|
+
{input:"Sigma", tag:"mo", output:"\u03A3", tex:null, ttype:CONST},
|
138
|
+
{input:"tau", tag:"mi", output:"\u03C4", tex:null, ttype:CONST},
|
139
|
+
{input:"theta", tag:"mi", output:"\u03B8", tex:null, ttype:CONST},
|
140
|
+
{input:"vartheta", tag:"mi", output:"\u03D1", tex:null, ttype:CONST},
|
141
|
+
{input:"Theta", tag:"mo", output:"\u0398", tex:null, ttype:CONST},
|
142
|
+
{input:"upsilon", tag:"mi", output:"\u03C5", tex:null, ttype:CONST},
|
143
|
+
{input:"xi", tag:"mi", output:"\u03BE", tex:null, ttype:CONST},
|
144
|
+
{input:"Xi", tag:"mo", output:"\u039E", tex:null, ttype:CONST},
|
145
|
+
{input:"zeta", tag:"mi", output:"\u03B6", tex:null, ttype:CONST},
|
146
|
+
|
147
|
+
//binary operation symbols
|
148
|
+
{input:"*", tag:"mo", output:"\u22C5", tex:"cdot", ttype:CONST},
|
149
|
+
{input:"**", tag:"mo", output:"\u22C6", tex:"star", ttype:CONST},
|
150
|
+
{input:"//", tag:"mo", output:"/", tex:null, ttype:CONST},
|
151
|
+
{input:"\\\\", tag:"mo", output:"\\", tex:"backslash", ttype:CONST},
|
152
|
+
{input:"setminus", tag:"mo", output:"\\", tex:null, ttype:CONST},
|
153
|
+
{input:"xx", tag:"mo", output:"\u00D7", tex:"times", ttype:CONST},
|
154
|
+
{input:"-:", tag:"mo", output:"\u00F7", tex:"divide", ttype:CONST},
|
155
|
+
{input:"@", tag:"mo", output:"\u2218", tex:"circ", ttype:CONST},
|
156
|
+
{input:"o+", tag:"mo", output:"\u2295", tex:"oplus", ttype:CONST},
|
157
|
+
{input:"ox", tag:"mo", output:"\u2297", tex:"otimes", ttype:CONST},
|
158
|
+
{input:"o.", tag:"mo", output:"\u2299", tex:"odot", ttype:CONST},
|
159
|
+
{input:"sum", tag:"mo", output:"\u2211", tex:null, ttype:UNDEROVER},
|
160
|
+
{input:"prod", tag:"mo", output:"\u220F", tex:null, ttype:UNDEROVER},
|
161
|
+
{input:"^^", tag:"mo", output:"\u2227", tex:"wedge", ttype:CONST},
|
162
|
+
{input:"^^^", tag:"mo", output:"\u22C0", tex:"bigwedge", ttype:UNDEROVER},
|
163
|
+
{input:"vv", tag:"mo", output:"\u2228", tex:"vee", ttype:CONST},
|
164
|
+
{input:"vvv", tag:"mo", output:"\u22C1", tex:"bigvee", ttype:UNDEROVER},
|
165
|
+
{input:"nn", tag:"mo", output:"\u2229", tex:"cap", ttype:CONST},
|
166
|
+
{input:"nnn", tag:"mo", output:"\u22C2", tex:"bigcap", ttype:UNDEROVER},
|
167
|
+
{input:"uu", tag:"mo", output:"\u222A", tex:"cup", ttype:CONST},
|
168
|
+
{input:"uuu", tag:"mo", output:"\u22C3", tex:"bigcup", ttype:UNDEROVER},
|
169
|
+
|
170
|
+
//binary relation symbols
|
171
|
+
{input:"!=", tag:"mo", output:"\u2260", tex:"ne", ttype:CONST},
|
172
|
+
{input:":=", tag:"mo", output:":=", tex:null, ttype:CONST},
|
173
|
+
{input:"lt", tag:"mo", output:"<", tex:null, ttype:CONST},
|
174
|
+
{input:"<=", tag:"mo", output:"\u2264", tex:"le", ttype:CONST},
|
175
|
+
{input:"lt=", tag:"mo", output:"\u2264", tex:"leq", ttype:CONST},
|
176
|
+
{input:">=", tag:"mo", output:"\u2265", tex:"ge", ttype:CONST},
|
177
|
+
{input:"geq", tag:"mo", output:"\u2265", tex:null, ttype:CONST},
|
178
|
+
{input:"-<", tag:"mo", output:"\u227A", tex:"prec", ttype:CONST},
|
179
|
+
{input:"-lt", tag:"mo", output:"\u227A", tex:null, ttype:CONST},
|
180
|
+
{input:">-", tag:"mo", output:"\u227B", tex:"succ", ttype:CONST},
|
181
|
+
{input:"-<=", tag:"mo", output:"\u2AAF", tex:"preceq", ttype:CONST},
|
182
|
+
{input:">-=", tag:"mo", output:"\u2AB0", tex:"succeq", ttype:CONST},
|
183
|
+
{input:"in", tag:"mo", output:"\u2208", tex:null, ttype:CONST},
|
184
|
+
{input:"!in", tag:"mo", output:"\u2209", tex:"notin", ttype:CONST},
|
185
|
+
{input:"sub", tag:"mo", output:"\u2282", tex:"subset", ttype:CONST},
|
186
|
+
{input:"sup", tag:"mo", output:"\u2283", tex:"supset", ttype:CONST},
|
187
|
+
{input:"sube", tag:"mo", output:"\u2286", tex:"subseteq", ttype:CONST},
|
188
|
+
{input:"supe", tag:"mo", output:"\u2287", tex:"supseteq", ttype:CONST},
|
189
|
+
{input:"-=", tag:"mo", output:"\u2261", tex:"equiv", ttype:CONST},
|
190
|
+
{input:"~=", tag:"mo", output:"\u2245", tex:"cong", ttype:CONST},
|
191
|
+
{input:"~~", tag:"mo", output:"\u2248", tex:"approx", ttype:CONST},
|
192
|
+
{input:"prop", tag:"mo", output:"\u221D", tex:"propto", ttype:CONST},
|
193
|
+
|
194
|
+
//logical symbols
|
195
|
+
{input:"and", tag:"mtext", output:"and", tex:null, ttype:SPACE},
|
196
|
+
{input:"or", tag:"mtext", output:"or", tex:null, ttype:SPACE},
|
197
|
+
{input:"not", tag:"mo", output:"\u00AC", tex:"neg", ttype:CONST},
|
198
|
+
{input:"=>", tag:"mo", output:"\u21D2", tex:"implies", ttype:CONST},
|
199
|
+
{input:"if", tag:"mo", output:"if", tex:null, ttype:SPACE},
|
200
|
+
{input:"<=>", tag:"mo", output:"\u21D4", tex:"iff", ttype:CONST},
|
201
|
+
{input:"AA", tag:"mo", output:"\u2200", tex:"forall", ttype:CONST},
|
202
|
+
{input:"EE", tag:"mo", output:"\u2203", tex:"exists", ttype:CONST},
|
203
|
+
{input:"_|_", tag:"mo", output:"\u22A5", tex:"bot", ttype:CONST},
|
204
|
+
{input:"TT", tag:"mo", output:"\u22A4", tex:"top", ttype:CONST},
|
205
|
+
{input:"|--", tag:"mo", output:"\u22A2", tex:"vdash", ttype:CONST},
|
206
|
+
{input:"|==", tag:"mo", output:"\u22A8", tex:"models", ttype:CONST},
|
207
|
+
|
208
|
+
//grouping brackets
|
209
|
+
{input:"(", tag:"mo", output:"(", tex:null, ttype:LEFTBRACKET},
|
210
|
+
{input:")", tag:"mo", output:")", tex:null, ttype:RIGHTBRACKET},
|
211
|
+
{input:"[", tag:"mo", output:"[", tex:null, ttype:LEFTBRACKET},
|
212
|
+
{input:"]", tag:"mo", output:"]", tex:null, ttype:RIGHTBRACKET},
|
213
|
+
{input:"{", tag:"mo", output:"{", tex:null, ttype:LEFTBRACKET},
|
214
|
+
{input:"}", tag:"mo", output:"}", tex:null, ttype:RIGHTBRACKET},
|
215
|
+
{input:"|", tag:"mo", output:"|", tex:null, ttype:LEFTRIGHT},
|
216
|
+
//{input:"||", tag:"mo", output:"||", tex:null, ttype:LEFTRIGHT},
|
217
|
+
{input:"(:", tag:"mo", output:"\u2329", tex:"langle", ttype:LEFTBRACKET},
|
218
|
+
{input:":)", tag:"mo", output:"\u232A", tex:"rangle", ttype:RIGHTBRACKET},
|
219
|
+
{input:"<<", tag:"mo", output:"\u2329", tex:null, ttype:LEFTBRACKET},
|
220
|
+
{input:">>", tag:"mo", output:"\u232A", tex:null, ttype:RIGHTBRACKET},
|
221
|
+
{input:"{:", tag:"mo", output:"{:", tex:null, ttype:LEFTBRACKET, invisible:true},
|
222
|
+
{input:":}", tag:"mo", output:":}", tex:null, ttype:RIGHTBRACKET, invisible:true},
|
223
|
+
|
224
|
+
//miscellaneous symbols
|
225
|
+
{input:"int", tag:"mo", output:"\u222B", tex:null, ttype:CONST},
|
226
|
+
{input:"dx", tag:"mi", output:"{:d x:}", tex:null, ttype:DEFINITION},
|
227
|
+
{input:"dy", tag:"mi", output:"{:d y:}", tex:null, ttype:DEFINITION},
|
228
|
+
{input:"dz", tag:"mi", output:"{:d z:}", tex:null, ttype:DEFINITION},
|
229
|
+
{input:"dt", tag:"mi", output:"{:d t:}", tex:null, ttype:DEFINITION},
|
230
|
+
{input:"oint", tag:"mo", output:"\u222E", tex:null, ttype:CONST},
|
231
|
+
{input:"del", tag:"mo", output:"\u2202", tex:"partial", ttype:CONST},
|
232
|
+
{input:"grad", tag:"mo", output:"\u2207", tex:"nabla", ttype:CONST},
|
233
|
+
{input:"+-", tag:"mo", output:"\u00B1", tex:"pm", ttype:CONST},
|
234
|
+
{input:"O/", tag:"mo", output:"\u2205", tex:"emptyset", ttype:CONST},
|
235
|
+
{input:"oo", tag:"mo", output:"\u221E", tex:"infty", ttype:CONST},
|
236
|
+
{input:"aleph", tag:"mo", output:"\u2135", tex:null, ttype:CONST},
|
237
|
+
{input:"...", tag:"mo", output:"...", tex:"ldots", ttype:CONST},
|
238
|
+
{input:":.", tag:"mo", output:"\u2234", tex:"therefore", ttype:CONST},
|
239
|
+
{input:"/_", tag:"mo", output:"\u2220", tex:"angle", ttype:CONST},
|
240
|
+
{input:"\\ ", tag:"mo", output:"\u00A0", tex:null, ttype:CONST},
|
241
|
+
{input:"quad", tag:"mo", output:"\u00A0\u00A0", tex:null, ttype:CONST},
|
242
|
+
{input:"qquad", tag:"mo", output:"\u00A0\u00A0\u00A0\u00A0", tex:null, ttype:CONST},
|
243
|
+
{input:"cdots", tag:"mo", output:"\u22EF", tex:null, ttype:CONST},
|
244
|
+
{input:"vdots", tag:"mo", output:"\u22EE", tex:null, ttype:CONST},
|
245
|
+
{input:"ddots", tag:"mo", output:"\u22F1", tex:null, ttype:CONST},
|
246
|
+
{input:"diamond", tag:"mo", output:"\u22C4", tex:null, ttype:CONST},
|
247
|
+
{input:"square", tag:"mo", output:"\u25A1", tex:null, ttype:CONST},
|
248
|
+
{input:"|__", tag:"mo", output:"\u230A", tex:"lfloor", ttype:CONST},
|
249
|
+
{input:"__|", tag:"mo", output:"\u230B", tex:"rfloor", ttype:CONST},
|
250
|
+
{input:"|~", tag:"mo", output:"\u2308", tex:"lceiling", ttype:CONST},
|
251
|
+
{input:"~|", tag:"mo", output:"\u2309", tex:"rceiling", ttype:CONST},
|
252
|
+
{input:"CC", tag:"mo", output:"\u2102", tex:null, ttype:CONST},
|
253
|
+
{input:"NN", tag:"mo", output:"\u2115", tex:null, ttype:CONST},
|
254
|
+
{input:"QQ", tag:"mo", output:"\u211A", tex:null, ttype:CONST},
|
255
|
+
{input:"RR", tag:"mo", output:"\u211D", tex:null, ttype:CONST},
|
256
|
+
{input:"ZZ", tag:"mo", output:"\u2124", tex:null, ttype:CONST},
|
257
|
+
{input:"f", tag:"mi", output:"f", tex:null, ttype:UNARY, func:true},
|
258
|
+
{input:"g", tag:"mi", output:"g", tex:null, ttype:UNARY, func:true},
|
259
|
+
|
260
|
+
//standard functions
|
261
|
+
{input:"lim", tag:"mo", output:"lim", tex:null, ttype:UNDEROVER},
|
262
|
+
{input:"Lim", tag:"mo", output:"Lim", tex:null, ttype:UNDEROVER},
|
263
|
+
{input:"sin", tag:"mo", output:"sin", tex:null, ttype:UNARY, func:true},
|
264
|
+
{input:"cos", tag:"mo", output:"cos", tex:null, ttype:UNARY, func:true},
|
265
|
+
{input:"tan", tag:"mo", output:"tan", tex:null, ttype:UNARY, func:true},
|
266
|
+
{input:"sinh", tag:"mo", output:"sinh", tex:null, ttype:UNARY, func:true},
|
267
|
+
{input:"cosh", tag:"mo", output:"cosh", tex:null, ttype:UNARY, func:true},
|
268
|
+
{input:"tanh", tag:"mo", output:"tanh", tex:null, ttype:UNARY, func:true},
|
269
|
+
{input:"cot", tag:"mo", output:"cot", tex:null, ttype:UNARY, func:true},
|
270
|
+
{input:"sec", tag:"mo", output:"sec", tex:null, ttype:UNARY, func:true},
|
271
|
+
{input:"csc", tag:"mo", output:"csc", tex:null, ttype:UNARY, func:true},
|
272
|
+
{input:"log", tag:"mo", output:"log", tex:null, ttype:UNARY, func:true},
|
273
|
+
{input:"ln", tag:"mo", output:"ln", tex:null, ttype:UNARY, func:true},
|
274
|
+
{input:"det", tag:"mo", output:"det", tex:null, ttype:UNARY, func:true},
|
275
|
+
{input:"dim", tag:"mo", output:"dim", tex:null, ttype:CONST},
|
276
|
+
{input:"mod", tag:"mo", output:"mod", tex:null, ttype:CONST},
|
277
|
+
{input:"gcd", tag:"mo", output:"gcd", tex:null, ttype:UNARY, func:true},
|
278
|
+
{input:"lcm", tag:"mo", output:"lcm", tex:null, ttype:UNARY, func:true},
|
279
|
+
{input:"lub", tag:"mo", output:"lub", tex:null, ttype:CONST},
|
280
|
+
{input:"glb", tag:"mo", output:"glb", tex:null, ttype:CONST},
|
281
|
+
{input:"min", tag:"mo", output:"min", tex:null, ttype:UNDEROVER},
|
282
|
+
{input:"max", tag:"mo", output:"max", tex:null, ttype:UNDEROVER},
|
283
|
+
|
284
|
+
//arrows
|
285
|
+
{input:"uarr", tag:"mo", output:"\u2191", tex:"uparrow", ttype:CONST},
|
286
|
+
{input:"darr", tag:"mo", output:"\u2193", tex:"downarrow", ttype:CONST},
|
287
|
+
{input:"rarr", tag:"mo", output:"\u2192", tex:"rightarrow", ttype:CONST},
|
288
|
+
{input:"->", tag:"mo", output:"\u2192", tex:"to", ttype:CONST},
|
289
|
+
{input:"|->", tag:"mo", output:"\u21A6", tex:"mapsto", ttype:CONST},
|
290
|
+
{input:"larr", tag:"mo", output:"\u2190", tex:"leftarrow", ttype:CONST},
|
291
|
+
{input:"harr", tag:"mo", output:"\u2194", tex:"leftrightarrow", ttype:CONST},
|
292
|
+
{input:"rArr", tag:"mo", output:"\u21D2", tex:"Rightarrow", ttype:CONST},
|
293
|
+
{input:"lArr", tag:"mo", output:"\u21D0", tex:"Leftarrow", ttype:CONST},
|
294
|
+
{input:"hArr", tag:"mo", output:"\u21D4", tex:"Leftrightarrow", ttype:CONST},
|
295
|
+
|
296
|
+
//commands with argument
|
297
|
+
AMsqrt, AMroot, AMfrac, AMdiv, AMover, AMsub, AMsup,
|
298
|
+
{input:"hat", tag:"mover", output:"\u005E", tex:null, ttype:UNARY, acc:true},
|
299
|
+
{input:"bar", tag:"mover", output:"\u00AF", tex:"overline", ttype:UNARY, acc:true},
|
300
|
+
{input:"vec", tag:"mover", output:"\u2192", tex:null, ttype:UNARY, acc:true},
|
301
|
+
{input:"dot", tag:"mover", output:".", tex:null, ttype:UNARY, acc:true},
|
302
|
+
{input:"ddot", tag:"mover", output:"..", tex:null, ttype:UNARY, acc:true},
|
303
|
+
{input:"ul", tag:"munder", output:"\u0332", tex:"underline", ttype:UNARY, acc:true},
|
304
|
+
AMtext, AMmbox, AMquote,
|
305
|
+
{input:"bb", tag:"mstyle", atname:"fontweight", atval:"bold", output:"bb", tex:null, ttype:UNARY},
|
306
|
+
{input:"mathbf", tag:"mstyle", atname:"fontweight", atval:"bold", output:"mathbf", tex:null, ttype:UNARY},
|
307
|
+
{input:"sf", tag:"mstyle", atname:"fontfamily", atval:"sans-serif", output:"sf", tex:null, ttype:UNARY},
|
308
|
+
{input:"mathsf", tag:"mstyle", atname:"fontfamily", atval:"sans-serif", output:"mathsf", tex:null, ttype:UNARY},
|
309
|
+
{input:"bbb", tag:"mstyle", atname:"mathvariant", atval:"double-struck", output:"bbb", tex:null, ttype:UNARY, codes:AMbbb},
|
310
|
+
{input:"mathbb", tag:"mstyle", atname:"mathvariant", atval:"double-struck", output:"mathbb", tex:null, ttype:UNARY, codes:AMbbb},
|
311
|
+
{input:"cc", tag:"mstyle", atname:"mathvariant", atval:"script", output:"cc", tex:null, ttype:UNARY, codes:AMcal},
|
312
|
+
{input:"mathcal", tag:"mstyle", atname:"mathvariant", atval:"script", output:"mathcal", tex:null, ttype:UNARY, codes:AMcal},
|
313
|
+
{input:"tt", tag:"mstyle", atname:"fontfamily", atval:"monospace", output:"tt", tex:null, ttype:UNARY},
|
314
|
+
{input:"mathtt", tag:"mstyle", atname:"fontfamily", atval:"monospace", output:"mathtt", tex:null, ttype:UNARY},
|
315
|
+
{input:"fr", tag:"mstyle", atname:"mathvariant", atval:"fraktur", output:"fr", tex:null, ttype:UNARY, codes:AMfrk},
|
316
|
+
{input:"mathfrak", tag:"mstyle", atname:"mathvariant", atval:"fraktur", output:"mathfrak", tex:null, ttype:UNARY, codes:AMfrk}
|
317
|
+
];
|
318
|
+
|
319
|
+
function compareNames(s1,s2) {
|
320
|
+
if (s1.input > s2.input) return 1
|
321
|
+
else return -1;
|
322
|
+
}
|
323
|
+
|
324
|
+
var AMnames = []; //list of input symbols
|
325
|
+
|
326
|
+
function AMinitSymbols() {
|
327
|
+
var texsymbols = [], i;
|
328
|
+
for (i=0; i<AMsymbols.length; i++)
|
329
|
+
if (AMsymbols[i].tex)
|
330
|
+
texsymbols[texsymbols.length] = {input:AMsymbols[i].tex,
|
331
|
+
tag:AMsymbols[i].tag, output:AMsymbols[i].output, ttype:AMsymbols[i].ttype};
|
332
|
+
AMsymbols = AMsymbols.concat(texsymbols);
|
333
|
+
AMsymbols.sort(compareNames);
|
334
|
+
for (i=0; i<AMsymbols.length; i++) AMnames[i] = AMsymbols[i].input;
|
335
|
+
}
|
336
|
+
|
337
|
+
var AMmathml = "http://www.w3.org/1998/Math/MathML";
|
338
|
+
|
339
|
+
function AMcreateElementMathML(t) {
|
340
|
+
if (isIE) return document.createElement("m:"+t);
|
341
|
+
else return document.createElementNS(AMmathml,t);
|
342
|
+
}
|
343
|
+
|
344
|
+
function AMcreateMmlNode(t,frag) {
|
345
|
+
// var node = AMcreateElementMathML(name);
|
346
|
+
if (isIE) var node = document.createElement("m:"+t);
|
347
|
+
else var node = document.createElementNS(AMmathml,t);
|
348
|
+
node.appendChild(frag);
|
349
|
+
return node;
|
350
|
+
}
|
351
|
+
|
352
|
+
function newcommand(oldstr,newstr) {
|
353
|
+
AMsymbols = AMsymbols.concat([{input:oldstr, tag:"mo", output:newstr,
|
354
|
+
tex:null, ttype:DEFINITION}]);
|
355
|
+
}
|
356
|
+
|
357
|
+
function AMremoveCharsAndBlanks(str,n) {
|
358
|
+
//remove n characters and any following blanks
|
359
|
+
var st;
|
360
|
+
if (str.charAt(n)=="\\" && str.charAt(n+1)!="\\" && str.charAt(n+1)!=" ")
|
361
|
+
st = str.slice(n+1);
|
362
|
+
else st = str.slice(n);
|
363
|
+
for (var i=0; i<st.length && st.charCodeAt(i)<=32; i=i+1);
|
364
|
+
return st.slice(i);
|
365
|
+
}
|
366
|
+
|
367
|
+
function AMposition(arr, str, n) {
|
368
|
+
// return position >=n where str appears or would be inserted
|
369
|
+
// assumes arr is sorted
|
370
|
+
if (n==0) {
|
371
|
+
var h,m;
|
372
|
+
n = -1;
|
373
|
+
h = arr.length;
|
374
|
+
while (n+1<h) {
|
375
|
+
m = (n+h) >> 1;
|
376
|
+
if (arr[m]<str) n = m; else h = m;
|
377
|
+
}
|
378
|
+
return h;
|
379
|
+
} else
|
380
|
+
for (var i=n; i<arr.length && arr[i]<str; i++);
|
381
|
+
return i; // i=arr.length || arr[i]>=str
|
382
|
+
}
|
383
|
+
|
384
|
+
function AMgetSymbol(str) {
|
385
|
+
//return maximal initial substring of str that appears in names
|
386
|
+
//return null if there is none
|
387
|
+
var k = 0; //new pos
|
388
|
+
var j = 0; //old pos
|
389
|
+
var mk; //match pos
|
390
|
+
var st;
|
391
|
+
var tagst;
|
392
|
+
var match = "";
|
393
|
+
var more = true;
|
394
|
+
for (var i=1; i<=str.length && more; i++) {
|
395
|
+
st = str.slice(0,i); //initial substring of length i
|
396
|
+
j = k;
|
397
|
+
k = AMposition(AMnames, st, j);
|
398
|
+
if (k<AMnames.length && str.slice(0,AMnames[k].length)==AMnames[k]){
|
399
|
+
match = AMnames[k];
|
400
|
+
mk = k;
|
401
|
+
i = match.length;
|
402
|
+
}
|
403
|
+
more = k<AMnames.length && str.slice(0,AMnames[k].length)>=AMnames[k];
|
404
|
+
}
|
405
|
+
AMpreviousSymbol=AMcurrentSymbol;
|
406
|
+
if (match!=""){
|
407
|
+
AMcurrentSymbol=AMsymbols[mk].ttype;
|
408
|
+
return AMsymbols[mk];
|
409
|
+
}
|
410
|
+
// if str[0] is a digit or - return maxsubstring of digits.digits
|
411
|
+
AMcurrentSymbol=CONST;
|
412
|
+
k = 1;
|
413
|
+
st = str.slice(0,1);
|
414
|
+
var integ = true;
|
415
|
+
while ("0"<=st && st<="9" && k<=str.length) {
|
416
|
+
st = str.slice(k,k+1);
|
417
|
+
k++;
|
418
|
+
}
|
419
|
+
if (st == decimalsign) {
|
420
|
+
st = str.slice(k,k+1);
|
421
|
+
if ("0"<=st && st<="9") {
|
422
|
+
integ = false;
|
423
|
+
k++;
|
424
|
+
while ("0"<=st && st<="9" && k<=str.length) {
|
425
|
+
st = str.slice(k,k+1);
|
426
|
+
k++;
|
427
|
+
}
|
428
|
+
}
|
429
|
+
}
|
430
|
+
if ((integ && k>1) || k>2) {
|
431
|
+
st = str.slice(0,k-1);
|
432
|
+
tagst = "mn";
|
433
|
+
} else {
|
434
|
+
k = 2;
|
435
|
+
st = str.slice(0,1); //take 1 character
|
436
|
+
tagst = (("A">st || st>"Z") && ("a">st || st>"z")?"mo":"mi");
|
437
|
+
}
|
438
|
+
if (st=="-" && AMpreviousSymbol==INFIX) {
|
439
|
+
AMcurrentSymbol = INFIX; //trick "/" into recognizing "-" on second parse
|
440
|
+
return {input:st, tag:tagst, output:st, ttype:UNARY, func:true};
|
441
|
+
}
|
442
|
+
return {input:st, tag:tagst, output:st, ttype:CONST};
|
443
|
+
}
|
444
|
+
|
445
|
+
function AMremoveBrackets(node) {
|
446
|
+
var st;
|
447
|
+
if (node.nodeName=="mrow") {
|
448
|
+
st = node.firstChild.firstChild.nodeValue;
|
449
|
+
if (st=="(" || st=="[" || st=="{") node.removeChild(node.firstChild);
|
450
|
+
}
|
451
|
+
if (node.nodeName=="mrow") {
|
452
|
+
st = node.lastChild.firstChild.nodeValue;
|
453
|
+
if (st==")" || st=="]" || st=="}") node.removeChild(node.lastChild);
|
454
|
+
}
|
455
|
+
}
|
456
|
+
|
457
|
+
/*Parsing ASCII math expressions with the following grammar
|
458
|
+
v ::= [A-Za-z] | greek letters | numbers | other constant symbols
|
459
|
+
u ::= sqrt | text | bb | other unary symbols for font commands
|
460
|
+
b ::= frac | root | stackrel binary symbols
|
461
|
+
l ::= ( | [ | { | (: | {: left brackets
|
462
|
+
r ::= ) | ] | } | :) | :} right brackets
|
463
|
+
S ::= v | lEr | uS | bSS Simple expression
|
464
|
+
I ::= S_S | S^S | S_S^S | S Intermediate expression
|
465
|
+
E ::= IE | I/I Expression
|
466
|
+
Each terminal symbol is translated into a corresponding mathml node.*/
|
467
|
+
|
468
|
+
var AMnestingDepth,AMpreviousSymbol,AMcurrentSymbol;
|
469
|
+
|
470
|
+
function AMparseSexpr(str) { //parses str and returns [node,tailstr]
|
471
|
+
var symbol, node, result, i, st,// rightvert = false,
|
472
|
+
newFrag = document.createDocumentFragment();
|
473
|
+
str = AMremoveCharsAndBlanks(str,0);
|
474
|
+
symbol = AMgetSymbol(str); //either a token or a bracket or empty
|
475
|
+
if (symbol == null || symbol.ttype == RIGHTBRACKET && AMnestingDepth > 0) {
|
476
|
+
return [null,str];
|
477
|
+
}
|
478
|
+
if (symbol.ttype == DEFINITION) {
|
479
|
+
str = symbol.output+AMremoveCharsAndBlanks(str,symbol.input.length);
|
480
|
+
symbol = AMgetSymbol(str);
|
481
|
+
}
|
482
|
+
switch (symbol.ttype) {
|
483
|
+
case UNDEROVER:
|
484
|
+
case CONST:
|
485
|
+
str = AMremoveCharsAndBlanks(str,symbol.input.length);
|
486
|
+
return [AMcreateMmlNode(symbol.tag, //its a constant
|
487
|
+
document.createTextNode(symbol.output)),str];
|
488
|
+
case LEFTBRACKET: //read (expr+)
|
489
|
+
AMnestingDepth++;
|
490
|
+
str = AMremoveCharsAndBlanks(str,symbol.input.length);
|
491
|
+
result = AMparseExpr(str,true);
|
492
|
+
AMnestingDepth--;
|
493
|
+
if (typeof symbol.invisible == "boolean" && symbol.invisible)
|
494
|
+
node = AMcreateMmlNode("mrow",result[0]);
|
495
|
+
else {
|
496
|
+
node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
|
497
|
+
node = AMcreateMmlNode("mrow",node);
|
498
|
+
node.appendChild(result[0]);
|
499
|
+
}
|
500
|
+
return [node,result[1]];
|
501
|
+
case TEXT:
|
502
|
+
if (symbol!=AMquote) str = AMremoveCharsAndBlanks(str,symbol.input.length);
|
503
|
+
if (str.charAt(0)=="{") i=str.indexOf("}");
|
504
|
+
else if (str.charAt(0)=="(") i=str.indexOf(")");
|
505
|
+
else if (str.charAt(0)=="[") i=str.indexOf("]");
|
506
|
+
else if (symbol==AMquote) i=str.slice(1).indexOf("\"")+1;
|
507
|
+
else i = 0;
|
508
|
+
if (i==-1) i = str.length;
|
509
|
+
st = str.slice(1,i);
|
510
|
+
if (st.charAt(0) == " ") {
|
511
|
+
node = AMcreateElementMathML("mspace");
|
512
|
+
node.setAttribute("width","1ex");
|
513
|
+
newFrag.appendChild(node);
|
514
|
+
}
|
515
|
+
newFrag.appendChild(
|
516
|
+
AMcreateMmlNode(symbol.tag,document.createTextNode(st)));
|
517
|
+
if (st.charAt(st.length-1) == " ") {
|
518
|
+
node = AMcreateElementMathML("mspace");
|
519
|
+
node.setAttribute("width","1ex");
|
520
|
+
newFrag.appendChild(node);
|
521
|
+
}
|
522
|
+
str = AMremoveCharsAndBlanks(str,i+1);
|
523
|
+
return [AMcreateMmlNode("mrow",newFrag),str];
|
524
|
+
case UNARY:
|
525
|
+
str = AMremoveCharsAndBlanks(str,symbol.input.length);
|
526
|
+
result = AMparseSexpr(str);
|
527
|
+
if (result[0]==null) return [AMcreateMmlNode(symbol.tag,
|
528
|
+
document.createTextNode(symbol.output)),str];
|
529
|
+
if (typeof symbol.func == "boolean" && symbol.func) { // functions hack
|
530
|
+
st = str.charAt(0);
|
531
|
+
if (st=="^" || st=="_" || st=="/" || st=="|" || st==",") {
|
532
|
+
return [AMcreateMmlNode(symbol.tag,
|
533
|
+
document.createTextNode(symbol.output)),str];
|
534
|
+
} else {
|
535
|
+
node = AMcreateMmlNode("mrow",
|
536
|
+
AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)));
|
537
|
+
node.appendChild(result[0]);
|
538
|
+
return [node,result[1]];
|
539
|
+
}
|
540
|
+
}
|
541
|
+
AMremoveBrackets(result[0]);
|
542
|
+
if (symbol.input == "sqrt") { // sqrt
|
543
|
+
return [AMcreateMmlNode(symbol.tag,result[0]),result[1]];
|
544
|
+
} else if (typeof symbol.acc == "boolean" && symbol.acc) { // accent
|
545
|
+
node = AMcreateMmlNode(symbol.tag,result[0]);
|
546
|
+
node.appendChild(AMcreateMmlNode("mo",document.createTextNode(symbol.output)));
|
547
|
+
return [node,result[1]];
|
548
|
+
} else { // font change command
|
549
|
+
if (!isIE && typeof symbol.codes != "undefined") {
|
550
|
+
for (i=0; i<result[0].childNodes.length; i++)
|
551
|
+
if (result[0].childNodes[i].nodeName=="mi" || result[0].nodeName=="mi") {
|
552
|
+
st = (result[0].nodeName=="mi"?result[0].firstChild.nodeValue:
|
553
|
+
result[0].childNodes[i].firstChild.nodeValue);
|
554
|
+
var newst = [];
|
555
|
+
for (var j=0; j<st.length; j++)
|
556
|
+
if (st.charCodeAt(j)>64 && st.charCodeAt(j)<91) newst = newst +
|
557
|
+
String.fromCharCode(symbol.codes[st.charCodeAt(j)-65]);
|
558
|
+
else newst = newst + st.charAt(j);
|
559
|
+
if (result[0].nodeName=="mi")
|
560
|
+
result[0]=AMcreateElementMathML("mo").
|
561
|
+
appendChild(document.createTextNode(newst));
|
562
|
+
else result[0].replaceChild(AMcreateElementMathML("mo").
|
563
|
+
appendChild(document.createTextNode(newst)),result[0].childNodes[i]);
|
564
|
+
}
|
565
|
+
}
|
566
|
+
node = AMcreateMmlNode(symbol.tag,result[0]);
|
567
|
+
node.setAttribute(symbol.atname,symbol.atval);
|
568
|
+
return [node,result[1]];
|
569
|
+
}
|
570
|
+
case BINARY:
|
571
|
+
str = AMremoveCharsAndBlanks(str,symbol.input.length);
|
572
|
+
result = AMparseSexpr(str);
|
573
|
+
if (result[0]==null) return [AMcreateMmlNode("mo",
|
574
|
+
document.createTextNode(symbol.input)),str];
|
575
|
+
AMremoveBrackets(result[0]);
|
576
|
+
var result2 = AMparseSexpr(result[1]);
|
577
|
+
if (result2[0]==null) return [AMcreateMmlNode("mo",
|
578
|
+
document.createTextNode(symbol.input)),str];
|
579
|
+
AMremoveBrackets(result2[0]);
|
580
|
+
if (symbol.input=="root" || symbol.input=="stackrel")
|
581
|
+
newFrag.appendChild(result2[0]);
|
582
|
+
newFrag.appendChild(result[0]);
|
583
|
+
if (symbol.input=="frac") newFrag.appendChild(result2[0]);
|
584
|
+
return [AMcreateMmlNode(symbol.tag,newFrag),result2[1]];
|
585
|
+
case INFIX:
|
586
|
+
str = AMremoveCharsAndBlanks(str,symbol.input.length);
|
587
|
+
return [AMcreateMmlNode("mo",document.createTextNode(symbol.output)),str];
|
588
|
+
case SPACE:
|
589
|
+
str = AMremoveCharsAndBlanks(str,symbol.input.length);
|
590
|
+
node = AMcreateElementMathML("mspace");
|
591
|
+
node.setAttribute("width","1ex");
|
592
|
+
newFrag.appendChild(node);
|
593
|
+
newFrag.appendChild(
|
594
|
+
AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)));
|
595
|
+
node = AMcreateElementMathML("mspace");
|
596
|
+
node.setAttribute("width","1ex");
|
597
|
+
newFrag.appendChild(node);
|
598
|
+
return [AMcreateMmlNode("mrow",newFrag),str];
|
599
|
+
case LEFTRIGHT:
|
600
|
+
// if (rightvert) return [null,str]; else rightvert = true;
|
601
|
+
AMnestingDepth++;
|
602
|
+
str = AMremoveCharsAndBlanks(str,symbol.input.length);
|
603
|
+
result = AMparseExpr(str,false);
|
604
|
+
AMnestingDepth--;
|
605
|
+
var st = "";
|
606
|
+
if (result[0].lastChild!=null)
|
607
|
+
st = result[0].lastChild.firstChild.nodeValue;
|
608
|
+
if (st == "|") { // its an absolute value subterm
|
609
|
+
node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
|
610
|
+
node = AMcreateMmlNode("mrow",node);
|
611
|
+
node.appendChild(result[0]);
|
612
|
+
return [node,result[1]];
|
613
|
+
} else { // the "|" is a \mid
|
614
|
+
node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
|
615
|
+
node = AMcreateMmlNode("mrow",node);
|
616
|
+
return [node,str];
|
617
|
+
}
|
618
|
+
default:
|
619
|
+
//alert("default");
|
620
|
+
str = AMremoveCharsAndBlanks(str,symbol.input.length);
|
621
|
+
return [AMcreateMmlNode(symbol.tag, //its a constant
|
622
|
+
document.createTextNode(symbol.output)),str];
|
623
|
+
}
|
624
|
+
}
|
625
|
+
|
626
|
+
function AMparseIexpr(str) {
|
627
|
+
var symbol, sym1, sym2, node, result, underover;
|
628
|
+
str = AMremoveCharsAndBlanks(str,0);
|
629
|
+
sym1 = AMgetSymbol(str);
|
630
|
+
result = AMparseSexpr(str);
|
631
|
+
node = result[0];
|
632
|
+
str = result[1];
|
633
|
+
symbol = AMgetSymbol(str);
|
634
|
+
if (symbol.ttype == INFIX && symbol.input != "/") {
|
635
|
+
str = AMremoveCharsAndBlanks(str,symbol.input.length);
|
636
|
+
// if (symbol.input == "/") result = AMparseIexpr(str); else ...
|
637
|
+
result = AMparseSexpr(str);
|
638
|
+
if (result[0] == null) // show box in place of missing argument
|
639
|
+
result[0] = AMcreateMmlNode("mo",document.createTextNode("\u25A1"));
|
640
|
+
else AMremoveBrackets(result[0]);
|
641
|
+
str = result[1];
|
642
|
+
// if (symbol.input == "/") AMremoveBrackets(node);
|
643
|
+
if (symbol.input == "_") {
|
644
|
+
sym2 = AMgetSymbol(str);
|
645
|
+
underover = (sym1.ttype == UNDEROVER);
|
646
|
+
if (sym2.input == "^") {
|
647
|
+
str = AMremoveCharsAndBlanks(str,sym2.input.length);
|
648
|
+
var res2 = AMparseSexpr(str);
|
649
|
+
AMremoveBrackets(res2[0]);
|
650
|
+
str = res2[1];
|
651
|
+
node = AMcreateMmlNode((underover?"munderover":"msubsup"),node);
|
652
|
+
node.appendChild(result[0]);
|
653
|
+
node.appendChild(res2[0]);
|
654
|
+
node = AMcreateMmlNode("mrow",node); // so sum does not stretch
|
655
|
+
} else {
|
656
|
+
node = AMcreateMmlNode((underover?"munder":"msub"),node);
|
657
|
+
node.appendChild(result[0]);
|
658
|
+
}
|
659
|
+
} else {
|
660
|
+
node = AMcreateMmlNode(symbol.tag,node);
|
661
|
+
node.appendChild(result[0]);
|
662
|
+
}
|
663
|
+
}
|
664
|
+
return [node,str];
|
665
|
+
}
|
666
|
+
|
667
|
+
function AMparseExpr(str,rightbracket) {
|
668
|
+
var symbol, node, result, i, nodeList = [],
|
669
|
+
newFrag = document.createDocumentFragment();
|
670
|
+
do {
|
671
|
+
str = AMremoveCharsAndBlanks(str,0);
|
672
|
+
result = AMparseIexpr(str);
|
673
|
+
node = result[0];
|
674
|
+
str = result[1];
|
675
|
+
symbol = AMgetSymbol(str);
|
676
|
+
if (symbol.ttype == INFIX && symbol.input == "/") {
|
677
|
+
str = AMremoveCharsAndBlanks(str,symbol.input.length);
|
678
|
+
result = AMparseIexpr(str);
|
679
|
+
if (result[0] == null) // show box in place of missing argument
|
680
|
+
result[0] = AMcreateMmlNode("mo",document.createTextNode("\u25A1"));
|
681
|
+
else AMremoveBrackets(result[0]);
|
682
|
+
str = result[1];
|
683
|
+
AMremoveBrackets(node);
|
684
|
+
node = AMcreateMmlNode(symbol.tag,node);
|
685
|
+
node.appendChild(result[0]);
|
686
|
+
newFrag.appendChild(node);
|
687
|
+
symbol = AMgetSymbol(str);
|
688
|
+
}
|
689
|
+
else if (node!=undefined) newFrag.appendChild(node);
|
690
|
+
} while ((symbol.ttype != RIGHTBRACKET &&
|
691
|
+
(symbol.ttype != LEFTRIGHT || rightbracket)
|
692
|
+
|| AMnestingDepth == 0) && symbol!=null && symbol.output!="");
|
693
|
+
if (symbol.ttype == RIGHTBRACKET || symbol.ttype == LEFTRIGHT) {
|
694
|
+
// if (AMnestingDepth > 0) AMnestingDepth--;
|
695
|
+
var len = newFrag.childNodes.length;
|
696
|
+
if (len>0 && newFrag.childNodes[len-1].nodeName == "mrow" && len>1 &&
|
697
|
+
newFrag.childNodes[len-2].nodeName == "mo" &&
|
698
|
+
newFrag.childNodes[len-2].firstChild.nodeValue == ",") { //matrix
|
699
|
+
var right = newFrag.childNodes[len-1].lastChild.firstChild.nodeValue;
|
700
|
+
if (right==")" || right=="]") {
|
701
|
+
var left = newFrag.childNodes[len-1].firstChild.firstChild.nodeValue;
|
702
|
+
if (left=="(" && right==")" && symbol.output != "}" ||
|
703
|
+
left=="[" && right=="]") {
|
704
|
+
var pos = []; // positions of commas
|
705
|
+
var matrix = true;
|
706
|
+
var m = newFrag.childNodes.length;
|
707
|
+
for (i=0; matrix && i<m; i=i+2) {
|
708
|
+
pos[i] = [];
|
709
|
+
node = newFrag.childNodes[i];
|
710
|
+
if (matrix) matrix = node.nodeName=="mrow" &&
|
711
|
+
(i==m-1 || node.nextSibling.nodeName=="mo" &&
|
712
|
+
node.nextSibling.firstChild.nodeValue==",")&&
|
713
|
+
node.firstChild.firstChild.nodeValue==left &&
|
714
|
+
node.lastChild.firstChild.nodeValue==right;
|
715
|
+
if (matrix)
|
716
|
+
for (var j=0; j<node.childNodes.length; j++)
|
717
|
+
if (node.childNodes[j].firstChild.nodeValue==",")
|
718
|
+
pos[i][pos[i].length]=j;
|
719
|
+
if (matrix && i>1) matrix = pos[i].length == pos[i-2].length;
|
720
|
+
}
|
721
|
+
if (matrix) {
|
722
|
+
var row, frag, n, k, table = document.createDocumentFragment();
|
723
|
+
for (i=0; i<m; i=i+2) {
|
724
|
+
row = document.createDocumentFragment();
|
725
|
+
frag = document.createDocumentFragment();
|
726
|
+
node = newFrag.firstChild; // <mrow>(-,-,...,-,-)</mrow>
|
727
|
+
n = node.childNodes.length;
|
728
|
+
k = 0;
|
729
|
+
node.removeChild(node.firstChild); //remove (
|
730
|
+
for (j=1; j<n-1; j++) {
|
731
|
+
if (typeof pos[i][k] != "undefined" && j==pos[i][k]){
|
732
|
+
node.removeChild(node.firstChild); //remove ,
|
733
|
+
row.appendChild(AMcreateMmlNode("mtd",frag));
|
734
|
+
k++;
|
735
|
+
} else frag.appendChild(node.firstChild);
|
736
|
+
}
|
737
|
+
row.appendChild(AMcreateMmlNode("mtd",frag));
|
738
|
+
if (newFrag.childNodes.length>2) {
|
739
|
+
newFrag.removeChild(newFrag.firstChild); //remove <mrow>)</mrow>
|
740
|
+
newFrag.removeChild(newFrag.firstChild); //remove <mo>,</mo>
|
741
|
+
}
|
742
|
+
table.appendChild(AMcreateMmlNode("mtr",row));
|
743
|
+
}
|
744
|
+
node = AMcreateMmlNode("mtable",table);
|
745
|
+
if (typeof symbol.invisible == "boolean" && symbol.invisible) node.setAttribute("columnalign","left");
|
746
|
+
newFrag.replaceChild(node,newFrag.firstChild);
|
747
|
+
}
|
748
|
+
}
|
749
|
+
}
|
750
|
+
}
|
751
|
+
str = AMremoveCharsAndBlanks(str,symbol.input.length);
|
752
|
+
if (typeof symbol.invisible != "boolean" || !symbol.invisible) {
|
753
|
+
node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
|
754
|
+
newFrag.appendChild(node);
|
755
|
+
}
|
756
|
+
}
|
757
|
+
return [newFrag,str];
|
758
|
+
}
|
759
|
+
|
760
|
+
function AMparseMath(str) {
|
761
|
+
var result, node = AMcreateElementMathML("mstyle");
|
762
|
+
if (mathcolor != "") node.setAttribute("mathcolor",mathcolor);
|
763
|
+
if (displaystyle) node.setAttribute("displaystyle","true");
|
764
|
+
if (mathfontfamily != "") node.setAttribute("fontfamily",mathfontfamily);
|
765
|
+
AMnestingDepth = 0;
|
766
|
+
node.appendChild(AMparseExpr(str.replace(/^\s+/g,""),false)[0]);
|
767
|
+
node = AMcreateMmlNode("math",node);
|
768
|
+
if (showasciiformulaonhover) //fixed by djhsu so newline
|
769
|
+
node.setAttribute("title",str.replace(/\s+/g," "));//does not show in Gecko
|
770
|
+
if (mathfontfamily != "" && (isIE || mathfontfamily != "serif")) {
|
771
|
+
var fnode = AMcreateElementXHTML("font");
|
772
|
+
fnode.setAttribute("face",mathfontfamily);
|
773
|
+
fnode.appendChild(node);
|
774
|
+
return fnode;
|
775
|
+
}
|
776
|
+
return node;
|
777
|
+
}
|
778
|
+
|
779
|
+
function AMstrarr2docFrag(arr, linebreaks) {
|
780
|
+
var newFrag=document.createDocumentFragment();
|
781
|
+
var expr = false;
|
782
|
+
for (var i=0; i<arr.length; i++) {
|
783
|
+
if (expr) newFrag.appendChild(AMparseMath(arr[i]));
|
784
|
+
else {
|
785
|
+
var arri = (linebreaks ? arr[i].split("\n\n") : [arr[i]]);
|
786
|
+
newFrag.appendChild(AMcreateElementXHTML("span").
|
787
|
+
appendChild(document.createTextNode(arri[0])));
|
788
|
+
for (var j=1; j<arri.length; j++) {
|
789
|
+
newFrag.appendChild(AMcreateElementXHTML("p"));
|
790
|
+
newFrag.appendChild(AMcreateElementXHTML("span").
|
791
|
+
appendChild(document.createTextNode(arri[j])));
|
792
|
+
}
|
793
|
+
}
|
794
|
+
expr = !expr;
|
795
|
+
}
|
796
|
+
return newFrag;
|
797
|
+
}
|
798
|
+
|
799
|
+
function AMprocessNodeR(n, linebreaks) {
|
800
|
+
var mtch, str, arr, frg, i;
|
801
|
+
if (n.childNodes.length == 0) {
|
802
|
+
if ((n.nodeType!=8 || linebreaks) &&
|
803
|
+
n.parentNode.nodeName!="form" && n.parentNode.nodeName!="FORM" &&
|
804
|
+
n.parentNode.nodeName!="textarea" && n.parentNode.nodeName!="TEXTAREA" &&
|
805
|
+
n.parentNode.nodeName!="pre" && n.parentNode.nodeName!="PRE") {
|
806
|
+
str = n.nodeValue;
|
807
|
+
if (!(str == null)) {
|
808
|
+
str = str.replace(/\r\n\r\n/g,"\n\n");
|
809
|
+
if (doubleblankmathdelimiter) {
|
810
|
+
str = str.replace(/\x20\x20\./g," "+AMdelimiter1+".");
|
811
|
+
str = str.replace(/\x20\x20,/g," "+AMdelimiter1+",");
|
812
|
+
str = str.replace(/\x20\x20/g," "+AMdelimiter1+" ");
|
813
|
+
}
|
814
|
+
str = str.replace(/\x20+/g," ");
|
815
|
+
str = str.replace(/\s*\r\n/g," ");
|
816
|
+
mtch = false;
|
817
|
+
str = str.replace(new RegExp(AMescape2, "g"),
|
818
|
+
function(st){mtch=true;return "AMescape2"});
|
819
|
+
str = str.replace(new RegExp(AMescape1, "g"),
|
820
|
+
function(st){mtch=true;return "AMescape1"});
|
821
|
+
str = str.replace(new RegExp(AMdelimiter2regexp, "g"),AMdelimiter1);
|
822
|
+
arr = str.split(AMdelimiter1);
|
823
|
+
for (i=0; i<arr.length; i++)
|
824
|
+
arr[i]=arr[i].replace(/AMescape2/g,AMdelimiter2).
|
825
|
+
replace(/AMescape1/g,AMdelimiter1);
|
826
|
+
if (arr.length>1 || mtch) {
|
827
|
+
if (checkForMathML) {
|
828
|
+
checkForMathML = false;
|
829
|
+
var nd = AMisMathMLavailable();
|
830
|
+
AMnoMathML = nd != null;
|
831
|
+
if (AMnoMathML && notifyIfNoMathML)
|
832
|
+
if (alertIfNoMathML)
|
833
|
+
alert("To view the ASCIIMathML notation use Internet Explorer 6 +\nMathPlayer (free from www.dessci.com)\n\
|
834
|
+
or Firefox/Mozilla/Netscape");
|
835
|
+
else AMbody.insertBefore(nd,AMbody.childNodes[0]);
|
836
|
+
}
|
837
|
+
if (!AMnoMathML) {
|
838
|
+
frg = AMstrarr2docFrag(arr,n.nodeType==8);
|
839
|
+
var len = frg.childNodes.length;
|
840
|
+
n.parentNode.replaceChild(frg,n);
|
841
|
+
return len-1;
|
842
|
+
} else return 0;
|
843
|
+
}
|
844
|
+
}
|
845
|
+
} else return 0;
|
846
|
+
} else if (n.nodeName!="math") {
|
847
|
+
for (i=0; i<n.childNodes.length; i++)
|
848
|
+
i += AMprocessNodeR(n.childNodes[i], linebreaks);
|
849
|
+
}
|
850
|
+
return 0;
|
851
|
+
}
|
852
|
+
|
853
|
+
function AMprocessNode(n, linebreaks, spanclassAM) {
|
854
|
+
var frag,st;
|
855
|
+
if (spanclassAM!=null) {
|
856
|
+
frag = document.getElementsByTagName("span")
|
857
|
+
for (var i=0;i<frag.length;i++)
|
858
|
+
if (frag[i].className == "AM")
|
859
|
+
AMprocessNodeR(frag[i],linebreaks);
|
860
|
+
} else {
|
861
|
+
try {
|
862
|
+
st = n.innerHTML;
|
863
|
+
} catch(err) {}
|
864
|
+
if (st==null ||
|
865
|
+
st.indexOf(AMdelimiter1)!=-1 || st.indexOf(AMdelimiter2)!=-1)
|
866
|
+
AMprocessNodeR(n,linebreaks);
|
867
|
+
}
|
868
|
+
if (isIE) { //needed to match size and font of formula to surrounding text
|
869
|
+
frag = document.getElementsByTagName('math');
|
870
|
+
for (var i=0;i<frag.length;i++) frag[i].update()
|
871
|
+
}
|
872
|
+
}
|
873
|
+
|
874
|
+
var AMbody;
|
875
|
+
var AMnoMathML = false, AMtranslated = false;
|
876
|
+
|
877
|
+
function translate(spanclassAM) {
|
878
|
+
if (!AMtranslated) { // run this only once
|
879
|
+
AMtranslated = true;
|
880
|
+
AMinitSymbols();
|
881
|
+
AMbody = document.getElementsByTagName("body")[0];
|
882
|
+
AMprocessNode(AMbody, false, spanclassAM);
|
883
|
+
}
|
884
|
+
}
|
885
|
+
|
886
|
+
if (isIE) { // avoid adding MathPlayer info explicitly to each webpage
|
887
|
+
document.write("<object id=\"mathplayer\"\
|
888
|
+
classid=\"clsid:32F66A20-7614-11D4-BD11-00104BD3F987\"></object>");
|
889
|
+
document.write("<?import namespace=\"m\" implementation=\"#mathplayer\"?>");
|
890
|
+
}
|
891
|
+
|
892
|
+
// GO1.1 Generic onload by Brothercake
|
893
|
+
// http://www.brothercake.com/
|
894
|
+
//onload function (replaces the onload="translate()" in the <body> tag)
|
895
|
+
function generic()
|
896
|
+
{
|
897
|
+
translate();
|
898
|
+
};
|
899
|
+
//setup onload function
|
900
|
+
if(typeof window.addEventListener != 'undefined')
|
901
|
+
{
|
902
|
+
//.. gecko, safari, konqueror and standard
|
903
|
+
window.addEventListener('load', generic, false);
|
904
|
+
}
|
905
|
+
else if(typeof document.addEventListener != 'undefined')
|
906
|
+
{
|
907
|
+
//.. opera 7
|
908
|
+
document.addEventListener('load', generic, false);
|
909
|
+
}
|
910
|
+
else if(typeof window.attachEvent != 'undefined')
|
911
|
+
{
|
912
|
+
//.. win/ie
|
913
|
+
window.attachEvent('onload', generic);
|
914
|
+
}
|
915
|
+
//** remove this condition to degrade older browsers
|
916
|
+
else
|
917
|
+
{
|
918
|
+
//.. mac/ie5 and anything else that gets this far
|
919
|
+
//if there's an existing onload function
|
920
|
+
if(typeof window.onload == 'function')
|
921
|
+
{
|
922
|
+
//store it
|
923
|
+
var existing = onload;
|
924
|
+
//add new onload handler
|
925
|
+
window.onload = function()
|
926
|
+
{
|
927
|
+
//call existing onload function
|
928
|
+
existing();
|
929
|
+
//call generic onload function
|
930
|
+
generic();
|
931
|
+
};
|
932
|
+
}
|
933
|
+
else
|
934
|
+
{
|
935
|
+
//setup onload function
|
936
|
+
window.onload = generic;
|
937
|
+
}
|
938
|
+
}
|