FooBarWidget-mizuho 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.markdown +68 -0
  3. data/Rakefile +9 -0
  4. data/asciidoc/BUGS +34 -0
  5. data/asciidoc/BUGS.txt +28 -0
  6. data/asciidoc/CHANGELOG +1585 -0
  7. data/asciidoc/CHANGELOG.txt +1595 -0
  8. data/asciidoc/COPYING +339 -0
  9. data/asciidoc/COPYRIGHT +18 -0
  10. data/asciidoc/INSTALL +82 -0
  11. data/asciidoc/INSTALL.txt +71 -0
  12. data/asciidoc/README +46 -0
  13. data/asciidoc/README.txt +36 -0
  14. data/asciidoc/a2x +641 -0
  15. data/asciidoc/asciidoc.conf +404 -0
  16. data/asciidoc/asciidoc.py +4255 -0
  17. data/asciidoc/common.aap +9 -0
  18. data/asciidoc/dblatex/asciidoc-dblatex.sty +18 -0
  19. data/asciidoc/dblatex/asciidoc-dblatex.xsl +17 -0
  20. data/asciidoc/dblatex/dblatex-readme.txt +22 -0
  21. data/asciidoc/doc/a2x.1 +246 -0
  22. data/asciidoc/doc/a2x.1.txt +195 -0
  23. data/asciidoc/doc/article.css-embedded.html +579 -0
  24. data/asciidoc/doc/article.html +62 -0
  25. data/asciidoc/doc/article.pdf +0 -0
  26. data/asciidoc/doc/article.txt +124 -0
  27. data/asciidoc/doc/asciidoc-revhistory.xml +27 -0
  28. data/asciidoc/doc/asciidoc.1 +161 -0
  29. data/asciidoc/doc/asciidoc.1.css-embedded.html +562 -0
  30. data/asciidoc/doc/asciidoc.1.css.html +212 -0
  31. data/asciidoc/doc/asciidoc.1.html +190 -0
  32. data/asciidoc/doc/asciidoc.1.txt +118 -0
  33. data/asciidoc/doc/asciidoc.conf +8 -0
  34. data/asciidoc/doc/asciidoc.css-embedded.html +7954 -0
  35. data/asciidoc/doc/asciidoc.css.html +7553 -0
  36. data/asciidoc/doc/asciidoc.dict +673 -0
  37. data/asciidoc/doc/asciidoc.html +3502 -0
  38. data/asciidoc/doc/asciidoc.txt +4757 -0
  39. data/asciidoc/doc/asciimath.txt +47 -0
  40. data/asciidoc/doc/book-multi.css-embedded.html +575 -0
  41. data/asciidoc/doc/book-multi.html +72 -0
  42. data/asciidoc/doc/book-multi.txt +159 -0
  43. data/asciidoc/doc/book.css-embedded.html +585 -0
  44. data/asciidoc/doc/book.html +60 -0
  45. data/asciidoc/doc/book.txt +133 -0
  46. data/asciidoc/doc/customers.csv +18 -0
  47. data/asciidoc/doc/faq.txt +262 -0
  48. data/asciidoc/doc/latex-backend.html +224 -0
  49. data/asciidoc/doc/latex-backend.txt +193 -0
  50. data/asciidoc/doc/latexmath.txt +35 -0
  51. data/asciidoc/doc/main.aap +293 -0
  52. data/asciidoc/doc/music-filter.html +513 -0
  53. data/asciidoc/doc/music-filter.pdf +0 -0
  54. data/asciidoc/doc/music-filter.txt +158 -0
  55. data/asciidoc/doc/source-highlight-filter.html +183 -0
  56. data/asciidoc/doc/source-highlight-filter.pdf +0 -0
  57. data/asciidoc/doc/source-highlight-filter.txt +174 -0
  58. data/asciidoc/docbook-xsl/asciidoc-docbook-xsl.txt +71 -0
  59. data/asciidoc/docbook-xsl/chunked.xsl +19 -0
  60. data/asciidoc/docbook-xsl/common.xsl +67 -0
  61. data/asciidoc/docbook-xsl/fo.xsl +117 -0
  62. data/asciidoc/docbook-xsl/htmlhelp.xsl +17 -0
  63. data/asciidoc/docbook-xsl/manpage.xsl +28 -0
  64. data/asciidoc/docbook-xsl/shaded-literallayout.patch +32 -0
  65. data/asciidoc/docbook-xsl/xhtml.xsl +14 -0
  66. data/asciidoc/docbook.conf +606 -0
  67. data/asciidoc/examples/website/CHANGELOG.html +3828 -0
  68. data/asciidoc/examples/website/INSTALL.html +163 -0
  69. data/asciidoc/examples/website/README-website.html +129 -0
  70. data/asciidoc/examples/website/README-website.txt +29 -0
  71. data/asciidoc/examples/website/README.html +125 -0
  72. data/asciidoc/examples/website/a2x.1.html +395 -0
  73. data/asciidoc/examples/website/asciidoc-docbook-xsl.html +165 -0
  74. data/asciidoc/examples/website/asciimath.html +157 -0
  75. data/asciidoc/examples/website/build-website.sh +25 -0
  76. data/asciidoc/examples/website/downloads.html +219 -0
  77. data/asciidoc/examples/website/downloads.txt +98 -0
  78. data/asciidoc/examples/website/faq.html +372 -0
  79. data/asciidoc/examples/website/index.html +398 -0
  80. data/asciidoc/examples/website/index.txt +222 -0
  81. data/asciidoc/examples/website/latex-backend.html +640 -0
  82. data/asciidoc/examples/website/latexmath.html +119 -0
  83. data/asciidoc/examples/website/layout1.conf +161 -0
  84. data/asciidoc/examples/website/layout1.css +65 -0
  85. data/asciidoc/examples/website/layout2.conf +158 -0
  86. data/asciidoc/examples/website/layout2.css +93 -0
  87. data/asciidoc/examples/website/manpage.html +266 -0
  88. data/asciidoc/examples/website/music-filter.html +242 -0
  89. data/asciidoc/examples/website/music1.abc +12 -0
  90. data/asciidoc/examples/website/music1.png +0 -0
  91. data/asciidoc/examples/website/music2.ly +9 -0
  92. data/asciidoc/examples/website/music2.png +0 -0
  93. data/asciidoc/examples/website/source-highlight-filter.html +251 -0
  94. data/asciidoc/examples/website/support.html +78 -0
  95. data/asciidoc/examples/website/support.txt +5 -0
  96. data/asciidoc/examples/website/userguide.html +7597 -0
  97. data/asciidoc/examples/website/version9.html +143 -0
  98. data/asciidoc/examples/website/version9.txt +48 -0
  99. data/asciidoc/filters/code-filter-readme.txt +37 -0
  100. data/asciidoc/filters/code-filter-test-c++.txt +7 -0
  101. data/asciidoc/filters/code-filter-test.txt +15 -0
  102. data/asciidoc/filters/code-filter.conf +8 -0
  103. data/asciidoc/filters/code-filter.py +239 -0
  104. data/asciidoc/filters/music-filter-test.txt +40 -0
  105. data/asciidoc/filters/music-filter.conf +40 -0
  106. data/asciidoc/filters/music2png.py +189 -0
  107. data/asciidoc/filters/source-highlight-filter-test.txt +19 -0
  108. data/asciidoc/filters/source-highlight-filter.conf +100 -0
  109. data/asciidoc/help.conf +213 -0
  110. data/asciidoc/html4.conf +363 -0
  111. data/asciidoc/images/highlighter.png +0 -0
  112. data/asciidoc/images/icons/README +5 -0
  113. data/asciidoc/images/icons/callouts/1.png +0 -0
  114. data/asciidoc/images/icons/callouts/10.png +0 -0
  115. data/asciidoc/images/icons/callouts/11.png +0 -0
  116. data/asciidoc/images/icons/callouts/12.png +0 -0
  117. data/asciidoc/images/icons/callouts/13.png +0 -0
  118. data/asciidoc/images/icons/callouts/14.png +0 -0
  119. data/asciidoc/images/icons/callouts/15.png +0 -0
  120. data/asciidoc/images/icons/callouts/2.png +0 -0
  121. data/asciidoc/images/icons/callouts/3.png +0 -0
  122. data/asciidoc/images/icons/callouts/4.png +0 -0
  123. data/asciidoc/images/icons/callouts/5.png +0 -0
  124. data/asciidoc/images/icons/callouts/6.png +0 -0
  125. data/asciidoc/images/icons/callouts/7.png +0 -0
  126. data/asciidoc/images/icons/callouts/8.png +0 -0
  127. data/asciidoc/images/icons/callouts/9.png +0 -0
  128. data/asciidoc/images/icons/caution.png +0 -0
  129. data/asciidoc/images/icons/example.png +0 -0
  130. data/asciidoc/images/icons/home.png +0 -0
  131. data/asciidoc/images/icons/important.png +0 -0
  132. data/asciidoc/images/icons/next.png +0 -0
  133. data/asciidoc/images/icons/note.png +0 -0
  134. data/asciidoc/images/icons/prev.png +0 -0
  135. data/asciidoc/images/icons/tip.png +0 -0
  136. data/asciidoc/images/icons/up.png +0 -0
  137. data/asciidoc/images/icons/warning.png +0 -0
  138. data/asciidoc/images/smallnew.png +0 -0
  139. data/asciidoc/images/tiger.png +0 -0
  140. data/asciidoc/install.sh +55 -0
  141. data/asciidoc/javascripts/ASCIIMathML.js +938 -0
  142. data/asciidoc/javascripts/LaTeXMathML.js +1223 -0
  143. data/asciidoc/javascripts/toc.js +69 -0
  144. data/asciidoc/lang-es.conf +15 -0
  145. data/asciidoc/latex.conf +663 -0
  146. data/asciidoc/linuxdoc.conf +285 -0
  147. data/asciidoc/math.conf +50 -0
  148. data/asciidoc/stylesheets/docbook-xsl.css +271 -0
  149. data/asciidoc/stylesheets/xhtml-deprecated-manpage.css +21 -0
  150. data/asciidoc/stylesheets/xhtml-deprecated.css +247 -0
  151. data/asciidoc/stylesheets/xhtml11-manpage.css +18 -0
  152. data/asciidoc/stylesheets/xhtml11-quirks.css +49 -0
  153. data/asciidoc/stylesheets/xhtml11.css +284 -0
  154. data/asciidoc/t.conf +20 -0
  155. data/asciidoc/text.conf +16 -0
  156. data/asciidoc/vim/ftdetect/asciidoc_filetype.vim +53 -0
  157. data/asciidoc/vim/syntax/asciidoc.vim +139 -0
  158. data/asciidoc/xhtml-deprecated-css.conf +235 -0
  159. data/asciidoc/xhtml-deprecated.conf +351 -0
  160. data/asciidoc/xhtml11-quirks.conf +57 -0
  161. data/asciidoc/xhtml11.conf +514 -0
  162. data/bin/mizuho +40 -0
  163. data/lib/mizuho/chapter.rb +54 -0
  164. data/lib/mizuho/generator.rb +106 -0
  165. data/lib/mizuho/heading.rb +46 -0
  166. data/lib/mizuho/parser.rb +99 -0
  167. data/lib/mizuho/template.rb +50 -0
  168. data/mizuho.gemspec +34 -0
  169. data/templates/asciidoc.css +358 -0
  170. data/templates/asciidoc.html.erb +86 -0
  171. data/templates/manualsonrails.css +165 -0
  172. data/templates/manualsonrails.html.erb +97 -0
  173. data/test/parser_spec.rb +190 -0
  174. data/test/spec_helper.rb +43 -0
  175. metadata +234 -0
@@ -0,0 +1,1223 @@
1
+ /*
2
+ LaTeXMathML.js
3
+ ==============
4
+
5
+ This file, in this form, is due to Douglas Woodall, June 2006.
6
+ It contains JavaScript functions to convert (most simple) LaTeX
7
+ math notation to Presentation MathML. It was obtained by
8
+ downloading the file ASCIIMathML.js from
9
+ http://www1.chapman.edu/~jipsen/mathml/asciimathdownload/
10
+ and modifying it so that it carries out ONLY those conversions
11
+ that would be carried out in LaTeX. A description of the original
12
+ file, with examples, can be found at
13
+ www1.chapman.edu/~jipsen/mathml/asciimath.html
14
+ ASCIIMathML: Math on the web for everyone
15
+
16
+ Here is the header notice from the original file:
17
+
18
+ ASCIIMathML.js
19
+ ==============
20
+ This file contains JavaScript functions to convert ASCII math notation
21
+ to Presentation MathML. The conversion is done while the (X)HTML page
22
+ loads, and should work with Firefox/Mozilla/Netscape 7+ and Internet
23
+ Explorer 6+MathPlayer (http://www.dessci.com/en/products/mathplayer/).
24
+ Just add the next line to your (X)HTML page with this file in the same folder:
25
+ This is a convenient and inexpensive solution for authoring MathML.
26
+
27
+ Version 1.4.7 Dec 15, 2005, (c) Peter Jipsen http://www.chapman.edu/~jipsen
28
+ Latest version at http://www.chapman.edu/~jipsen/mathml/ASCIIMathML.js
29
+ For changes see http://www.chapman.edu/~jipsen/mathml/asciimathchanges.txt
30
+ If you use it on a webpage, please send the URL to jipsen@chapman.edu
31
+
32
+ This program is free software; you can redistribute it and/or modify
33
+ it under the terms of the GNU General Public License as published by
34
+ the Free Software Foundation; either version 2 of the License, or (at
35
+ your option) any later version.
36
+
37
+ This program is distributed in the hope that it will be useful,
38
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
39
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40
+ General Public License (at http://www.gnu.org/copyleft/gpl.html)
41
+ for more details.
42
+
43
+ LaTeXMathML.js (ctd)
44
+ ==============
45
+
46
+ The instructions for use are the same as for the original
47
+ ASCIIMathML.js, except that of course the line you add to your
48
+ file should be
49
+ Or use absolute path names if the file is not in the same folder
50
+ as your (X)HTML page.
51
+ */
52
+
53
+ var checkForMathML = true; // check if browser can display MathML
54
+ var notifyIfNoMathML = true; // display note if no MathML capability
55
+ var alertIfNoMathML = false; // show alert box if no MathML capability
56
+ // was "red":
57
+ var mathcolor = ""; // change it to "" (to inherit) or any other color
58
+ // was "serif":
59
+ var mathfontfamily = ""; // change to "" to inherit (works in IE)
60
+ // or another family (e.g. "arial")
61
+ var showasciiformulaonhover = true; // helps students learn ASCIIMath
62
+ /*
63
+ // Commented out by DRW -- not now used -- see DELIMITERS (twice) near the end
64
+ var displaystyle = false; // puts limits above and below large operators
65
+ var decimalsign = "."; // change to "," if you like, beware of `(1,2)`!
66
+ var AMdelimiter1 = "`", AMescape1 = "\\\\`"; // can use other characters
67
+ var AMdelimiter2 = "$", AMescape2 = "\\\\\\$", AMdelimiter2regexp = "\\$";
68
+ var doubleblankmathdelimiter = false; // if true, x+1 is equal to `x+1`
69
+ // for IE this works only in <!-- -->
70
+ //var separatetokens;// has been removed (email me if this is a problem)
71
+ */
72
+ var isIE = document.createElementNS==null;
73
+
74
+ if (document.getElementById==null)
75
+ alert("This webpage requires a recent browser such as\
76
+ \nMozilla/Netscape 7+ or Internet Explorer 6+MathPlayer")
77
+
78
+ // all further global variables start with "AM"
79
+
80
+ function AMcreateElementXHTML(t) {
81
+ if (isIE) return document.createElement(t);
82
+ else return document.createElementNS("http://www.w3.org/1999/xhtml",t);
83
+ }
84
+
85
+ function AMnoMathMLNote() {
86
+ var nd = AMcreateElementXHTML("h3");
87
+ nd.setAttribute("align","center")
88
+ nd.appendChild(AMcreateElementXHTML("p"));
89
+ nd.appendChild(document.createTextNode("To view the "));
90
+ var an = AMcreateElementXHTML("a");
91
+ an.appendChild(document.createTextNode("LaTeXMathML"));
92
+ an.setAttribute("href","http://www.maths.nott.ac.uk/personal/drw/lm.html");
93
+ nd.appendChild(an);
94
+ nd.appendChild(document.createTextNode(" notation use Internet Explorer 6+"));
95
+ an = AMcreateElementXHTML("a");
96
+ an.appendChild(document.createTextNode("MathPlayer"));
97
+ an.setAttribute("href","http://www.dessci.com/en/products/mathplayer/download.htm");
98
+ nd.appendChild(an);
99
+ nd.appendChild(document.createTextNode(" or Netscape/Mozilla/Firefox"));
100
+ nd.appendChild(AMcreateElementXHTML("p"));
101
+ return nd;
102
+ }
103
+
104
+ function AMisMathMLavailable() {
105
+ if (navigator.appName.slice(0,8)=="Netscape")
106
+ if (navigator.appVersion.slice(0,1)>="5") return null;
107
+ else return AMnoMathMLNote();
108
+ else if (navigator.appName.slice(0,9)=="Microsoft")
109
+ try {
110
+ var ActiveX = new ActiveXObject("MathPlayer.Factory.1");
111
+ return null;
112
+ } catch (e) {
113
+ return AMnoMathMLNote();
114
+ }
115
+ else return AMnoMathMLNote();
116
+ }
117
+
118
+ // character lists for Mozilla/Netscape fonts
119
+ 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];
120
+ 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];
121
+ 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];
122
+
123
+ var CONST = 0, UNARY = 1, BINARY = 2, INFIX = 3, LEFTBRACKET = 4,
124
+ RIGHTBRACKET = 5, SPACE = 6, UNDEROVER = 7, DEFINITION = 8,
125
+ TEXT = 9, BIG = 10, LONG = 11, STRETCHY = 12, MATRIX = 13; // token types
126
+
127
+ var AMsqrt = {input:"\\sqrt", tag:"msqrt", output:"sqrt", ttype:UNARY},
128
+ AMroot = {input:"\\root", tag:"mroot", output:"root", ttype:BINARY},
129
+ AMfrac = {input:"\\frac", tag:"mfrac", output:"/", ttype:BINARY},
130
+ AMover = {input:"\\stackrel", tag:"mover", output:"stackrel", ttype:BINARY},
131
+ AMatop = {input:"\\atop", tag:"mfrac", output:"", ttype:INFIX},
132
+ AMchoose = {input:"\\choose", tag:"mfrac", output:"", ttype:INFIX},
133
+ AMsub = {input:"_", tag:"msub", output:"_", ttype:INFIX},
134
+ AMsup = {input:"^", tag:"msup", output:"^", ttype:INFIX},
135
+ AMtext = {input:"\\mathrm", tag:"mtext", output:"text", ttype:TEXT},
136
+ AMmbox = {input:"\\mbox", tag:"mtext", output:"mbox", ttype:TEXT};
137
+
138
+ // Commented out by DRW to prevent 1/2 turning into a 2-line fraction
139
+ // AMdiv = {input:"/", tag:"mfrac", output:"/", ttype:INFIX},
140
+ // Commented out by DRW so that " prints literally in equations
141
+ // AMquote = {input:"\"", tag:"mtext", output:"mbox", ttype:TEXT};
142
+
143
+ var AMsymbols = [
144
+ //Greek letters
145
+ {input:"\\alpha", tag:"mi", output:"\u03B1", ttype:CONST},
146
+ {input:"\\beta", tag:"mi", output:"\u03B2", ttype:CONST},
147
+ {input:"\\gamma", tag:"mi", output:"\u03B3", ttype:CONST},
148
+ {input:"\\delta", tag:"mi", output:"\u03B4", ttype:CONST},
149
+ {input:"\\epsilon", tag:"mi", output:"\u03B5", ttype:CONST},
150
+ {input:"\\varepsilon", tag:"mi", output:"\u025B", ttype:CONST},
151
+ {input:"\\zeta", tag:"mi", output:"\u03B6", ttype:CONST},
152
+ {input:"\\eta", tag:"mi", output:"\u03B7", ttype:CONST},
153
+ {input:"\\theta", tag:"mi", output:"\u03B8", ttype:CONST},
154
+ {input:"\\vartheta", tag:"mi", output:"\u03D1", ttype:CONST},
155
+ {input:"\\iota", tag:"mi", output:"\u03B9", ttype:CONST},
156
+ {input:"\\kappa", tag:"mi", output:"\u03BA", ttype:CONST},
157
+ {input:"\\lambda", tag:"mi", output:"\u03BB", ttype:CONST},
158
+ {input:"\\mu", tag:"mi", output:"\u03BC", ttype:CONST},
159
+ {input:"\\nu", tag:"mi", output:"\u03BD", ttype:CONST},
160
+ {input:"\\xi", tag:"mi", output:"\u03BE", ttype:CONST},
161
+ {input:"\\pi", tag:"mi", output:"\u03C0", ttype:CONST},
162
+ {input:"\\varpi", tag:"mi", output:"\u03D6", ttype:CONST},
163
+ {input:"\\rho", tag:"mi", output:"\u03C1", ttype:CONST},
164
+ {input:"\\varrho", tag:"mi", output:"\u03F1", ttype:CONST},
165
+ {input:"\\varsigma", tag:"mi", output:"\u03C2", ttype:CONST},
166
+ {input:"\\sigma", tag:"mi", output:"\u03C3", ttype:CONST},
167
+ {input:"\\tau", tag:"mi", output:"\u03C4", ttype:CONST},
168
+ {input:"\\upsilon", tag:"mi", output:"\u03C5", ttype:CONST},
169
+ {input:"\\phi", tag:"mi", output:"\u03C6", ttype:CONST},
170
+ {input:"\\varphi", tag:"mi", output:"\u03D5", ttype:CONST},
171
+ {input:"\\chi", tag:"mi", output:"\u03C7", ttype:CONST},
172
+ {input:"\\psi", tag:"mi", output:"\u03C8", ttype:CONST},
173
+ {input:"\\omega", tag:"mi", output:"\u03C9", ttype:CONST},
174
+ {input:"\\Gamma", tag:"mo", output:"\u0393", ttype:CONST},
175
+ {input:"\\Delta", tag:"mo", output:"\u0394", ttype:CONST},
176
+ {input:"\\Theta", tag:"mo", output:"\u0398", ttype:CONST},
177
+ {input:"\\Lambda", tag:"mo", output:"\u039B", ttype:CONST},
178
+ {input:"\\Xi", tag:"mo", output:"\u039E", ttype:CONST},
179
+ {input:"\\Pi", tag:"mo", output:"\u03A0", ttype:CONST},
180
+ {input:"\\Sigma", tag:"mo", output:"\u03A3", ttype:CONST},
181
+ {input:"\\Upsilon", tag:"mo", output:"\u03A5", ttype:CONST},
182
+ {input:"\\Phi", tag:"mo", output:"\u03A6", ttype:CONST},
183
+ {input:"\\Psi", tag:"mo", output:"\u03A8", ttype:CONST},
184
+ {input:"\\Omega", tag:"mo", output:"\u03A9", ttype:CONST},
185
+
186
+ //fractions
187
+ {input:"\\frac12", tag:"mo", output:"\u00BD", ttype:CONST},
188
+ {input:"\\frac14", tag:"mo", output:"\u00BC", ttype:CONST},
189
+ {input:"\\frac34", tag:"mo", output:"\u00BE", ttype:CONST},
190
+ {input:"\\frac13", tag:"mo", output:"\u2153", ttype:CONST},
191
+ {input:"\\frac23", tag:"mo", output:"\u2154", ttype:CONST},
192
+ {input:"\\frac15", tag:"mo", output:"\u2155", ttype:CONST},
193
+ {input:"\\frac25", tag:"mo", output:"\u2156", ttype:CONST},
194
+ {input:"\\frac35", tag:"mo", output:"\u2157", ttype:CONST},
195
+ {input:"\\frac45", tag:"mo", output:"\u2158", ttype:CONST},
196
+ {input:"\\frac16", tag:"mo", output:"\u2159", ttype:CONST},
197
+ {input:"\\frac56", tag:"mo", output:"\u215A", ttype:CONST},
198
+ {input:"\\frac18", tag:"mo", output:"\u215B", ttype:CONST},
199
+ {input:"\\frac38", tag:"mo", output:"\u215C", ttype:CONST},
200
+ {input:"\\frac58", tag:"mo", output:"\u215D", ttype:CONST},
201
+ {input:"\\frac78", tag:"mo", output:"\u215E", ttype:CONST},
202
+
203
+ //binary operation symbols
204
+ {input:"\\pm", tag:"mo", output:"\u00B1", ttype:CONST},
205
+ {input:"\\mp", tag:"mo", output:"\u2213", ttype:CONST},
206
+ {input:"\\triangleleft",tag:"mo", output:"\u22B2", ttype:CONST},
207
+ {input:"\\triangleright",tag:"mo",output:"\u22B3", ttype:CONST},
208
+ {input:"\\cdot", tag:"mo", output:"\u22C5", ttype:CONST},
209
+ {input:"\\star", tag:"mo", output:"\u22C6", ttype:CONST},
210
+ {input:"\\ast", tag:"mo", output:"\u002A", ttype:CONST},
211
+ {input:"\\times", tag:"mo", output:"\u00D7", ttype:CONST},
212
+ {input:"\\div", tag:"mo", output:"\u00F7", ttype:CONST},
213
+ {input:"\\circ", tag:"mo", output:"\u2218", ttype:CONST},
214
+ //{input:"\\bullet", tag:"mo", output:"\u2219", ttype:CONST},
215
+ {input:"\\bullet", tag:"mo", output:"\u2022", ttype:CONST},
216
+ {input:"\\oplus", tag:"mo", output:"\u2295", ttype:CONST},
217
+ {input:"\\ominus", tag:"mo", output:"\u2296", ttype:CONST},
218
+ {input:"\\otimes", tag:"mo", output:"\u2297", ttype:CONST},
219
+ {input:"\\bigcirc", tag:"mo", output:"\u25CB", ttype:CONST},
220
+ {input:"\\oslash", tag:"mo", output:"\u2298", ttype:CONST},
221
+ {input:"\\odot", tag:"mo", output:"\u2299", ttype:CONST},
222
+ {input:"\\land", tag:"mo", output:"\u2227", ttype:CONST},
223
+ {input:"\\wedge", tag:"mo", output:"\u2227", ttype:CONST},
224
+ {input:"\\lor", tag:"mo", output:"\u2228", ttype:CONST},
225
+ {input:"\\vee", tag:"mo", output:"\u2228", ttype:CONST},
226
+ {input:"\\cap", tag:"mo", output:"\u2229", ttype:CONST},
227
+ {input:"\\cup", tag:"mo", output:"\u222A", ttype:CONST},
228
+ {input:"\\sqcap", tag:"mo", output:"\u2293", ttype:CONST},
229
+ {input:"\\sqcup", tag:"mo", output:"\u2294", ttype:CONST},
230
+ {input:"\\uplus", tag:"mo", output:"\u228E", ttype:CONST},
231
+ {input:"\\amalg", tag:"mo", output:"\u2210", ttype:CONST},
232
+ {input:"\\bigtriangleup",tag:"mo",output:"\u25B3", ttype:CONST},
233
+ {input:"\\bigtriangledown",tag:"mo",output:"\u25BD", ttype:CONST},
234
+ {input:"\\dag", tag:"mo", output:"\u2020", ttype:CONST},
235
+ {input:"\\dagger", tag:"mo", output:"\u2020", ttype:CONST},
236
+ {input:"\\ddag", tag:"mo", output:"\u2021", ttype:CONST},
237
+ {input:"\\ddagger", tag:"mo", output:"\u2021", ttype:CONST},
238
+ {input:"\\lhd", tag:"mo", output:"\u22B2", ttype:CONST},
239
+ {input:"\\rhd", tag:"mo", output:"\u22B3", ttype:CONST},
240
+ {input:"\\unlhd", tag:"mo", output:"\u22B4", ttype:CONST},
241
+ {input:"\\unrhd", tag:"mo", output:"\u22B5", ttype:CONST},
242
+
243
+
244
+ //BIG Operators
245
+ {input:"\\sum", tag:"mo", output:"\u2211", ttype:UNDEROVER},
246
+ {input:"\\prod", tag:"mo", output:"\u220F", ttype:UNDEROVER},
247
+ {input:"\\bigcap", tag:"mo", output:"\u22C2", ttype:UNDEROVER},
248
+ {input:"\\bigcup", tag:"mo", output:"\u22C3", ttype:UNDEROVER},
249
+ {input:"\\bigwedge", tag:"mo", output:"\u22C0", ttype:UNDEROVER},
250
+ {input:"\\bigvee", tag:"mo", output:"\u22C1", ttype:UNDEROVER},
251
+ {input:"\\bigsqcap", tag:"mo", output:"\u2A05", ttype:UNDEROVER},
252
+ {input:"\\bigsqcup", tag:"mo", output:"\u2A06", ttype:UNDEROVER},
253
+ {input:"\\coprod", tag:"mo", output:"\u2210", ttype:UNDEROVER},
254
+ {input:"\\bigoplus", tag:"mo", output:"\u2A01", ttype:UNDEROVER},
255
+ {input:"\\bigotimes", tag:"mo", output:"\u2A02", ttype:UNDEROVER},
256
+ {input:"\\bigodot", tag:"mo", output:"\u2A00", ttype:UNDEROVER},
257
+ {input:"\\biguplus", tag:"mo", output:"\u2A04", ttype:UNDEROVER},
258
+ {input:"\\int", tag:"mo", output:"\u222B", ttype:CONST},
259
+ {input:"\\oint", tag:"mo", output:"\u222E", ttype:CONST},
260
+
261
+ //binary relation symbols
262
+ {input:":=", tag:"mo", output:":=", ttype:CONST},
263
+ {input:"\\lt", tag:"mo", output:"<", ttype:CONST},
264
+ {input:"\\gt", tag:"mo", output:">", ttype:CONST},
265
+ {input:"\\ne", tag:"mo", output:"\u2260", ttype:CONST},
266
+ {input:"\\neq", tag:"mo", output:"\u2260", ttype:CONST},
267
+ {input:"\\le", tag:"mo", output:"\u2264", ttype:CONST},
268
+ {input:"\\leq", tag:"mo", output:"\u2264", ttype:CONST},
269
+ {input:"\\leqslant", tag:"mo", output:"\u2264", ttype:CONST},
270
+ {input:"\\ge", tag:"mo", output:"\u2265", ttype:CONST},
271
+ {input:"\\geq", tag:"mo", output:"\u2265", ttype:CONST},
272
+ {input:"\\geqslant", tag:"mo", output:"\u2265", ttype:CONST},
273
+ {input:"\\equiv", tag:"mo", output:"\u2261", ttype:CONST},
274
+ {input:"\\ll", tag:"mo", output:"\u226A", ttype:CONST},
275
+ {input:"\\gg", tag:"mo", output:"\u226B", ttype:CONST},
276
+ {input:"\\doteq", tag:"mo", output:"\u2250", ttype:CONST},
277
+ {input:"\\prec", tag:"mo", output:"\u227A", ttype:CONST},
278
+ {input:"\\succ", tag:"mo", output:"\u227B", ttype:CONST},
279
+ {input:"\\preceq", tag:"mo", output:"\u227C", ttype:CONST},
280
+ {input:"\\succeq", tag:"mo", output:"\u227D", ttype:CONST},
281
+ {input:"\\subset", tag:"mo", output:"\u2282", ttype:CONST},
282
+ {input:"\\supset", tag:"mo", output:"\u2283", ttype:CONST},
283
+ {input:"\\subseteq", tag:"mo", output:"\u2286", ttype:CONST},
284
+ {input:"\\supseteq", tag:"mo", output:"\u2287", ttype:CONST},
285
+ {input:"\\sqsubset", tag:"mo", output:"\u228F", ttype:CONST},
286
+ {input:"\\sqsupset", tag:"mo", output:"\u2290", ttype:CONST},
287
+ {input:"\\sqsubseteq", tag:"mo", output:"\u2291", ttype:CONST},
288
+ {input:"\\sqsupseteq", tag:"mo", output:"\u2292", ttype:CONST},
289
+ {input:"\\sim", tag:"mo", output:"\u223C", ttype:CONST},
290
+ {input:"\\simeq", tag:"mo", output:"\u2243", ttype:CONST},
291
+ {input:"\\approx", tag:"mo", output:"\u2248", ttype:CONST},
292
+ {input:"\\cong", tag:"mo", output:"\u2245", ttype:CONST},
293
+ {input:"\\Join", tag:"mo", output:"\u22C8", ttype:CONST},
294
+ {input:"\\bowtie", tag:"mo", output:"\u22C8", ttype:CONST},
295
+ {input:"\\in", tag:"mo", output:"\u2208", ttype:CONST},
296
+ {input:"\\ni", tag:"mo", output:"\u220B", ttype:CONST},
297
+ {input:"\\owns", tag:"mo", output:"\u220B", ttype:CONST},
298
+ {input:"\\propto", tag:"mo", output:"\u221D", ttype:CONST},
299
+ {input:"\\vdash", tag:"mo", output:"\u22A2", ttype:CONST},
300
+ {input:"\\dashv", tag:"mo", output:"\u22A3", ttype:CONST},
301
+ {input:"\\models", tag:"mo", output:"\u22A8", ttype:CONST},
302
+ {input:"\\perp", tag:"mo", output:"\u22A5", ttype:CONST},
303
+ {input:"\\smile", tag:"mo", output:"\u2323", ttype:CONST},
304
+ {input:"\\frown", tag:"mo", output:"\u2322", ttype:CONST},
305
+ {input:"\\asymp", tag:"mo", output:"\u224D", ttype:CONST},
306
+ {input:"\\notin", tag:"mo", output:"\u2209", ttype:CONST},
307
+
308
+ //matrices
309
+ {input:"\\begin{eqnarray}", output:"X", ttype:MATRIX, invisible:true},
310
+ {input:"\\begin{array}", output:"X", ttype:MATRIX, invisible:true},
311
+ {input:"\\\\", output:"}&{", ttype:DEFINITION},
312
+ {input:"\\end{eqnarray}", output:"}}", ttype:DEFINITION},
313
+ {input:"\\end{array}", output:"}}", ttype:DEFINITION},
314
+
315
+ //grouping and literal brackets -- ieval is for IE
316
+ {input:"\\big", tag:"mo", output:"X", atval:"1.2", ieval:"2.2", ttype:BIG},
317
+ {input:"\\Big", tag:"mo", output:"X", atval:"1.6", ieval:"2.6", ttype:BIG},
318
+ {input:"\\bigg", tag:"mo", output:"X", atval:"2.2", ieval:"3.2", ttype:BIG},
319
+ {input:"\\Bigg", tag:"mo", output:"X", atval:"2.9", ieval:"3.9", ttype:BIG},
320
+ {input:"\\left", tag:"mo", output:"X", ttype:LEFTBRACKET},
321
+ {input:"\\right", tag:"mo", output:"X", ttype:RIGHTBRACKET},
322
+ {input:"{", output:"{", ttype:LEFTBRACKET, invisible:true},
323
+ {input:"}", output:"}", ttype:RIGHTBRACKET, invisible:true},
324
+
325
+ {input:"(", tag:"mo", output:"(", atval:"1", ttype:STRETCHY},
326
+ {input:"[", tag:"mo", output:"[", atval:"1", ttype:STRETCHY},
327
+ {input:"\\lbrack", tag:"mo", output:"[", atval:"1", ttype:STRETCHY},
328
+ {input:"\\{", tag:"mo", output:"{", atval:"1", ttype:STRETCHY},
329
+ {input:"\\lbrace", tag:"mo", output:"{", atval:"1", ttype:STRETCHY},
330
+ {input:"\\langle", tag:"mo", output:"\u2329", atval:"1", ttype:STRETCHY},
331
+ {input:"\\lfloor", tag:"mo", output:"\u230A", atval:"1", ttype:STRETCHY},
332
+ {input:"\\lceil", tag:"mo", output:"\u2308", atval:"1", ttype:STRETCHY},
333
+
334
+ // rtag:"mi" causes space to be inserted before a following sin, cos, etc.
335
+ // (see function AMparseExpr() )
336
+ {input:")", tag:"mo",output:")", rtag:"mi",atval:"1",ttype:STRETCHY},
337
+ {input:"]", tag:"mo",output:"]", rtag:"mi",atval:"1",ttype:STRETCHY},
338
+ {input:"\\rbrack",tag:"mo",output:"]", rtag:"mi",atval:"1",ttype:STRETCHY},
339
+ {input:"\\}", tag:"mo",output:"}", rtag:"mi",atval:"1",ttype:STRETCHY},
340
+ {input:"\\rbrace",tag:"mo",output:"}", rtag:"mi",atval:"1",ttype:STRETCHY},
341
+ {input:"\\rangle",tag:"mo",output:"\u232A", rtag:"mi",atval:"1",ttype:STRETCHY},
342
+ {input:"\\rfloor",tag:"mo",output:"\u230B", rtag:"mi",atval:"1",ttype:STRETCHY},
343
+ {input:"\\rceil", tag:"mo",output:"\u2309", rtag:"mi",atval:"1",ttype:STRETCHY},
344
+
345
+ // "|", "\\|", "\\vert" and "\\Vert" modified later: lspace = rspace = 0em
346
+ {input:"|", tag:"mo", output:"\u2223", atval:"1", ttype:STRETCHY},
347
+ {input:"\\|", tag:"mo", output:"\u2225", atval:"1", ttype:STRETCHY},
348
+ {input:"\\vert", tag:"mo", output:"\u2223", atval:"1", ttype:STRETCHY},
349
+ {input:"\\Vert", tag:"mo", output:"\u2225", atval:"1", ttype:STRETCHY},
350
+ {input:"\\mid", tag:"mo", output:"\u2223", atval:"1", ttype:STRETCHY},
351
+ {input:"\\parallel", tag:"mo", output:"\u2225", atval:"1", ttype:STRETCHY},
352
+ {input:"/", tag:"mo", output:"/", atval:"1.01", ttype:STRETCHY},
353
+ {input:"\\backslash", tag:"mo", output:"\u2216", atval:"1", ttype:STRETCHY},
354
+ {input:"\\setminus", tag:"mo", output:"\\", ttype:CONST},
355
+
356
+ //miscellaneous symbols
357
+ {input:"\\!", tag:"mspace", atname:"width", atval:"-0.167em", ttype:SPACE},
358
+ {input:"\\,", tag:"mspace", atname:"width", atval:"0.167em", ttype:SPACE},
359
+ {input:"\\>", tag:"mspace", atname:"width", atval:"0.222em", ttype:SPACE},
360
+ {input:"\\:", tag:"mspace", atname:"width", atval:"0.222em", ttype:SPACE},
361
+ {input:"\\;", tag:"mspace", atname:"width", atval:"0.278em", ttype:SPACE},
362
+ {input:"~", tag:"mspace", atname:"width", atval:"0.333em", ttype:SPACE},
363
+ {input:"\\quad", tag:"mspace", atname:"width", atval:"1em", ttype:SPACE},
364
+ {input:"\\qquad", tag:"mspace", atname:"width", atval:"2em", ttype:SPACE},
365
+ //{input:"{}", tag:"mo", output:"\u200B", ttype:CONST}, // zero-width
366
+ {input:"\\prime", tag:"mo", output:"\u2032", ttype:CONST},
367
+ {input:"'", tag:"mo", output:"\u02B9", ttype:CONST},
368
+ {input:"''", tag:"mo", output:"\u02BA", ttype:CONST},
369
+ {input:"'''", tag:"mo", output:"\u2034", ttype:CONST},
370
+ {input:"''''", tag:"mo", output:"\u2057", ttype:CONST},
371
+ {input:"\\ldots", tag:"mo", output:"\u2026", ttype:CONST},
372
+ {input:"\\cdots", tag:"mo", output:"\u22EF", ttype:CONST},
373
+ {input:"\\vdots", tag:"mo", output:"\u22EE", ttype:CONST},
374
+ {input:"\\ddots", tag:"mo", output:"\u22F1", ttype:CONST},
375
+ {input:"\\forall", tag:"mo", output:"\u2200", ttype:CONST},
376
+ {input:"\\exists", tag:"mo", output:"\u2203", ttype:CONST},
377
+ {input:"\\Re", tag:"mo", output:"\u211C", ttype:CONST},
378
+ {input:"\\Im", tag:"mo", output:"\u2111", ttype:CONST},
379
+ {input:"\\aleph", tag:"mo", output:"\u2135", ttype:CONST},
380
+ {input:"\\hbar", tag:"mo", output:"\u210F", ttype:CONST},
381
+ {input:"\\ell", tag:"mo", output:"\u2113", ttype:CONST},
382
+ {input:"\\wp", tag:"mo", output:"\u2118", ttype:CONST},
383
+ {input:"\\emptyset", tag:"mo", output:"\u2205", ttype:CONST},
384
+ {input:"\\infty", tag:"mo", output:"\u221E", ttype:CONST},
385
+ {input:"\\surd", tag:"mo", output:"\\sqrt{}", ttype:DEFINITION},
386
+ {input:"\\partial", tag:"mo", output:"\u2202", ttype:CONST},
387
+ {input:"\\nabla", tag:"mo", output:"\u2207", ttype:CONST},
388
+ {input:"\\triangle", tag:"mo", output:"\u25B3", ttype:CONST},
389
+ {input:"\\therefore", tag:"mo", output:"\u2234", ttype:CONST},
390
+ {input:"\\angle", tag:"mo", output:"\u2220", ttype:CONST},
391
+ //{input:"\\\\ ", tag:"mo", output:"\u00A0", ttype:CONST},
392
+ {input:"\\diamond", tag:"mo", output:"\u22C4", ttype:CONST},
393
+ //{input:"\\Diamond", tag:"mo", output:"\u25CA", ttype:CONST},
394
+ {input:"\\Diamond", tag:"mo", output:"\u25C7", ttype:CONST},
395
+ {input:"\\neg", tag:"mo", output:"\u00AC", ttype:CONST},
396
+ {input:"\\lnot", tag:"mo", output:"\u00AC", ttype:CONST},
397
+ {input:"\\bot", tag:"mo", output:"\u22A5", ttype:CONST},
398
+ {input:"\\top", tag:"mo", output:"\u22A4", ttype:CONST},
399
+ {input:"\\square", tag:"mo", output:"\u25AB", ttype:CONST},
400
+ {input:"\\Box", tag:"mo", output:"\u25A1", ttype:CONST},
401
+ {input:"\\wr", tag:"mo", output:"\u2240", ttype:CONST},
402
+
403
+ //standard functions
404
+ //Note UNDEROVER *must* have tag:"mo" to work properly
405
+ {input:"\\arccos", tag:"mi", output:"arccos", ttype:UNARY, func:true},
406
+ {input:"\\arcsin", tag:"mi", output:"arcsin", ttype:UNARY, func:true},
407
+ {input:"\\arctan", tag:"mi", output:"arctan", ttype:UNARY, func:true},
408
+ {input:"\\arg", tag:"mi", output:"arg", ttype:UNARY, func:true},
409
+ {input:"\\cos", tag:"mi", output:"cos", ttype:UNARY, func:true},
410
+ {input:"\\cosh", tag:"mi", output:"cosh", ttype:UNARY, func:true},
411
+ {input:"\\cot", tag:"mi", output:"cot", ttype:UNARY, func:true},
412
+ {input:"\\coth", tag:"mi", output:"coth", ttype:UNARY, func:true},
413
+ {input:"\\csc", tag:"mi", output:"csc", ttype:UNARY, func:true},
414
+ {input:"\\deg", tag:"mi", output:"deg", ttype:UNARY, func:true},
415
+ {input:"\\det", tag:"mi", output:"det", ttype:UNARY, func:true},
416
+ {input:"\\dim", tag:"mi", output:"dim", ttype:UNARY, func:true}, //CONST?
417
+ {input:"\\exp", tag:"mi", output:"exp", ttype:UNARY, func:true},
418
+ {input:"\\gcd", tag:"mi", output:"gcd", ttype:UNARY, func:true}, //CONST?
419
+ {input:"\\hom", tag:"mi", output:"hom", ttype:UNARY, func:true},
420
+ {input:"\\inf", tag:"mo", output:"inf", ttype:UNDEROVER},
421
+ {input:"\\ker", tag:"mi", output:"ker", ttype:UNARY, func:true},
422
+ {input:"\\lg", tag:"mi", output:"lg", ttype:UNARY, func:true},
423
+ {input:"\\lim", tag:"mo", output:"lim", ttype:UNDEROVER},
424
+ {input:"\\liminf", tag:"mo", output:"liminf", ttype:UNDEROVER},
425
+ {input:"\\limsup", tag:"mo", output:"limsup", ttype:UNDEROVER},
426
+ {input:"\\ln", tag:"mi", output:"ln", ttype:UNARY, func:true},
427
+ {input:"\\log", tag:"mi", output:"log", ttype:UNARY, func:true},
428
+ {input:"\\max", tag:"mo", output:"max", ttype:UNDEROVER},
429
+ {input:"\\min", tag:"mo", output:"min", ttype:UNDEROVER},
430
+ {input:"\\Pr", tag:"mi", output:"Pr", ttype:UNARY, func:true},
431
+ {input:"\\sec", tag:"mi", output:"sec", ttype:UNARY, func:true},
432
+ {input:"\\sin", tag:"mi", output:"sin", ttype:UNARY, func:true},
433
+ {input:"\\sinh", tag:"mi", output:"sinh", ttype:UNARY, func:true},
434
+ {input:"\\sup", tag:"mo", output:"sup", ttype:UNDEROVER},
435
+ {input:"\\tan", tag:"mi", output:"tan", ttype:UNARY, func:true},
436
+ {input:"\\tanh", tag:"mi", output:"tanh", ttype:UNARY, func:true},
437
+
438
+ //arrows
439
+ {input:"\\gets", tag:"mo", output:"\u2190", ttype:CONST},
440
+ {input:"\\leftarrow", tag:"mo", output:"\u2190", ttype:CONST},
441
+ {input:"\\to", tag:"mo", output:"\u2192", ttype:CONST},
442
+ {input:"\\rightarrow", tag:"mo", output:"\u2192", ttype:CONST},
443
+ {input:"\\leftrightarrow", tag:"mo", output:"\u2194", ttype:CONST},
444
+ {input:"\\uparrow", tag:"mo", output:"\u2191", ttype:CONST},
445
+ {input:"\\downarrow", tag:"mo", output:"\u2193", ttype:CONST},
446
+ {input:"\\updownarrow", tag:"mo", output:"\u2195", ttype:CONST},
447
+ {input:"\\Leftarrow", tag:"mo", output:"\u21D0", ttype:CONST},
448
+ {input:"\\Rightarrow", tag:"mo", output:"\u21D2", ttype:CONST},
449
+ {input:"\\Leftrightarrow", tag:"mo", output:"\u21D4", ttype:CONST},
450
+ {input:"\\iff", tag:"mo", output:"~\\Longleftrightarrow~", ttype:DEFINITION},
451
+ {input:"\\Uparrow", tag:"mo", output:"\u21D1", ttype:CONST},
452
+ {input:"\\Downarrow", tag:"mo", output:"\u21D3", ttype:CONST},
453
+ {input:"\\Updownarrow", tag:"mo", output:"\u21D5", ttype:CONST},
454
+ {input:"\\mapsto", tag:"mo", output:"\u21A6", ttype:CONST},
455
+ {input:"\\longleftarrow", tag:"mo", output:"\u2190", ttype:LONG},
456
+ {input:"\\longrightarrow", tag:"mo", output:"\u2192", ttype:LONG},
457
+ {input:"\\longleftrightarrow", tag:"mo", output:"\u2194", ttype:LONG},
458
+ {input:"\\Longleftarrow", tag:"mo", output:"\u21D0", ttype:LONG},
459
+ {input:"\\Longrightarrow", tag:"mo", output:"\u21D2", ttype:LONG},
460
+ {input:"\\Longleftrightarrow", tag:"mo", output:"\u21D4", ttype:LONG},
461
+ {input:"\\longmapsto", tag:"mo", output:"\u21A6", ttype:CONST},
462
+ // disaster if LONG
463
+
464
+ //commands with argument
465
+ AMsqrt, AMroot, AMfrac, AMover, AMsub, AMsup, AMtext, AMmbox, AMatop, AMchoose,
466
+ //AMdiv, AMquote,
467
+
468
+ //diacritical marks
469
+ {input:"\\acute", tag:"mover", output:"\u00B4", ttype:UNARY, acc:true},
470
+ //{input:"\\acute", tag:"mover", output:"\u0317", ttype:UNARY, acc:true},
471
+ //{input:"\\acute", tag:"mover", output:"\u0301", ttype:UNARY, acc:true},
472
+ //{input:"\\grave", tag:"mover", output:"\u0300", ttype:UNARY, acc:true},
473
+ //{input:"\\grave", tag:"mover", output:"\u0316", ttype:UNARY, acc:true},
474
+ {input:"\\grave", tag:"mover", output:"\u0060", ttype:UNARY, acc:true},
475
+ {input:"\\breve", tag:"mover", output:"\u02D8", ttype:UNARY, acc:true},
476
+ {input:"\\check", tag:"mover", output:"\u02C7", ttype:UNARY, acc:true},
477
+ {input:"\\dot", tag:"mover", output:".", ttype:UNARY, acc:true},
478
+ {input:"\\ddot", tag:"mover", output:"..", ttype:UNARY, acc:true},
479
+ //{input:"\\ddot", tag:"mover", output:"\u00A8", ttype:UNARY, acc:true},
480
+ {input:"\\mathring", tag:"mover", output:"\u00B0", ttype:UNARY, acc:true},
481
+ {input:"\\vec", tag:"mover", output:"\u20D7", ttype:UNARY, acc:true},
482
+ {input:"\\overrightarrow",tag:"mover",output:"\u20D7", ttype:UNARY, acc:true},
483
+ {input:"\\overleftarrow",tag:"mover", output:"\u20D6", ttype:UNARY, acc:true},
484
+ {input:"\\hat", tag:"mover", output:"\u005E", ttype:UNARY, acc:true},
485
+ {input:"\\widehat", tag:"mover", output:"\u0302", ttype:UNARY, acc:true},
486
+ {input:"\\tilde", tag:"mover", output:"~", ttype:UNARY, acc:true},
487
+ //{input:"\\tilde", tag:"mover", output:"\u0303", ttype:UNARY, acc:true},
488
+ {input:"\\widetilde", tag:"mover", output:"\u02DC", ttype:UNARY, acc:true},
489
+ {input:"\\bar", tag:"mover", output:"\u203E", ttype:UNARY, acc:true},
490
+ {input:"\\overbrace", tag:"mover", output:"\u23B4", ttype:UNARY, acc:true},
491
+ {input:"\\overline", tag:"mover", output:"\u00AF", ttype:UNARY, acc:true},
492
+ {input:"\\underbrace", tag:"munder", output:"\u23B5", ttype:UNARY, acc:true},
493
+ {input:"\\underline", tag:"munder", output:"\u00AF", ttype:UNARY, acc:true},
494
+ //{input:"underline", tag:"munder", output:"\u0332", ttype:UNARY, acc:true},
495
+
496
+ //typestyles and fonts
497
+ {input:"\\displaystyle",tag:"mstyle",atname:"displaystyle",atval:"true", ttype:UNARY},
498
+ {input:"\\textstyle",tag:"mstyle",atname:"displaystyle",atval:"false", ttype:UNARY},
499
+ {input:"\\scriptstyle",tag:"mstyle",atname:"scriptlevel",atval:"1", ttype:UNARY},
500
+ {input:"\\scriptscriptstyle",tag:"mstyle",atname:"scriptlevel",atval:"2", ttype:UNARY},
501
+ {input:"\\textrm", tag:"mstyle", output:"\\mathrm", ttype: DEFINITION},
502
+ {input:"\\mathbf", tag:"mstyle", atname:"mathvariant", atval:"bold", ttype:UNARY},
503
+ {input:"\\textbf", tag:"mstyle", atname:"mathvariant", atval:"bold", ttype:UNARY},
504
+ {input:"\\mathit", tag:"mstyle", atname:"mathvariant", atval:"italic", ttype:UNARY},
505
+ {input:"\\textit", tag:"mstyle", atname:"mathvariant", atval:"italic", ttype:UNARY},
506
+ {input:"\\mathtt", tag:"mstyle", atname:"mathvariant", atval:"monospace", ttype:UNARY},
507
+ {input:"\\texttt", tag:"mstyle", atname:"mathvariant", atval:"monospace", ttype:UNARY},
508
+ {input:"\\mathsf", tag:"mstyle", atname:"mathvariant", atval:"sans-serif", ttype:UNARY},
509
+ {input:"\\mathbb", tag:"mstyle", atname:"mathvariant", atval:"double-struck", ttype:UNARY, codes:AMbbb},
510
+ {input:"\\mathcal",tag:"mstyle", atname:"mathvariant", atval:"script", ttype:UNARY, codes:AMcal},
511
+ {input:"\\mathfrak",tag:"mstyle",atname:"mathvariant", atval:"fraktur",ttype:UNARY, codes:AMfrk}
512
+ ];
513
+
514
+ function compareNames(s1,s2) {
515
+ if (s1.input > s2.input) return 1
516
+ else return -1;
517
+ }
518
+
519
+ var AMnames = []; //list of input symbols
520
+
521
+ function AMinitSymbols() {
522
+ AMsymbols.sort(compareNames);
523
+ for (i=0; i<AMsymbols.length; i++) AMnames[i] = AMsymbols[i].input;
524
+ }
525
+
526
+ var AMmathml = "http://www.w3.org/1998/Math/MathML";
527
+
528
+ function AMcreateElementMathML(t) {
529
+ if (isIE) return document.createElement("m:"+t);
530
+ else return document.createElementNS(AMmathml,t);
531
+ }
532
+
533
+ function AMcreateMmlNode(t,frag) {
534
+ // var node = AMcreateElementMathML(name);
535
+ if (isIE) var node = document.createElement("m:"+t);
536
+ else var node = document.createElementNS(AMmathml,t);
537
+ node.appendChild(frag);
538
+ return node;
539
+ }
540
+
541
+ function newcommand(oldstr,newstr) {
542
+ AMsymbols = AMsymbols.concat([{input:oldstr, tag:"mo", output:newstr,
543
+ ttype:DEFINITION}]);
544
+ }
545
+
546
+ function AMremoveCharsAndBlanks(str,n) {
547
+ //remove n characters and any following blanks
548
+ var st;
549
+ st = str.slice(n);
550
+ for (var i=0; i<st.length && st.charCodeAt(i)<=32; i=i+1);
551
+ return st.slice(i);
552
+ }
553
+
554
+ function AMposition(arr, str, n) {
555
+ // return position >=n where str appears or would be inserted
556
+ // assumes arr is sorted
557
+ if (n==0) {
558
+ var h,m;
559
+ n = -1;
560
+ h = arr.length;
561
+ while (n+1<h) {
562
+ m = (n+h) >> 1;
563
+ if (arr[m]<str) n = m; else h = m;
564
+ }
565
+ return h;
566
+ } else
567
+ for (var i=n; i<arr.length && arr[i]<str; i++);
568
+ return i; // i=arr.length || arr[i]>=str
569
+ }
570
+
571
+ function AMgetSymbol(str) {
572
+ //return maximal initial substring of str that appears in names
573
+ //return null if there is none
574
+ var k = 0; //new pos
575
+ var j = 0; //old pos
576
+ var mk; //match pos
577
+ var st;
578
+ var tagst;
579
+ var match = "";
580
+ var more = true;
581
+ for (var i=1; i<=str.length && more; i++) {
582
+ st = str.slice(0,i); //initial substring of length i
583
+ j = k;
584
+ k = AMposition(AMnames, st, j);
585
+ if (k<AMnames.length && str.slice(0,AMnames[k].length)==AMnames[k]){
586
+ match = AMnames[k];
587
+ mk = k;
588
+ i = match.length;
589
+ }
590
+ more = k<AMnames.length && str.slice(0,AMnames[k].length)>=AMnames[k];
591
+ }
592
+ AMpreviousSymbol=AMcurrentSymbol;
593
+ if (match!=""){
594
+ AMcurrentSymbol=AMsymbols[mk].ttype;
595
+ return AMsymbols[mk];
596
+ }
597
+ AMcurrentSymbol=CONST;
598
+ k = 1;
599
+ st = str.slice(0,1); //take 1 character
600
+ if ("0"<=st && st<="9") tagst = "mn";
601
+ else tagst = (("A">st || st>"Z") && ("a">st || st>"z")?"mo":"mi");
602
+ /*
603
+ // Commented out by DRW (not fully understood, but probably to do with
604
+ // use of "/" as an INFIX version of "\\frac", which we don't want):
605
+ //}
606
+ //if (st=="-" && AMpreviousSymbol==INFIX) {
607
+ // AMcurrentSymbol = INFIX; //trick "/" into recognizing "-" on second parse
608
+ // return {input:st, tag:tagst, output:st, ttype:UNARY, func:true};
609
+ //}
610
+ */
611
+ return {input:st, tag:tagst, output:st, ttype:CONST};
612
+ }
613
+
614
+
615
+ /*Parsing ASCII math expressions with the following grammar
616
+ v ::= [A-Za-z] | greek letters | numbers | other constant symbols
617
+ u ::= sqrt | text | bb | other unary symbols for font commands
618
+ b ::= frac | root | stackrel binary symbols
619
+ l ::= { | \left left brackets
620
+ r ::= } | \right right brackets
621
+ S ::= v | lEr | uS | bSS Simple expression
622
+ I ::= S_S | S^S | S_S^S | S Intermediate expression
623
+ E ::= IE | I/I Expression
624
+ Each terminal symbol is translated into a corresponding mathml node.*/
625
+
626
+ var AMpreviousSymbol,AMcurrentSymbol;
627
+
628
+ function AMparseSexpr(str) { //parses str and returns [node,tailstr,(node)tag]
629
+ var symbol, node, result, result2, i, st,// rightvert = false,
630
+ newFrag = document.createDocumentFragment();
631
+ str = AMremoveCharsAndBlanks(str,0);
632
+ symbol = AMgetSymbol(str); //either a token or a bracket or empty
633
+ if (symbol == null || symbol.ttype == RIGHTBRACKET)
634
+ return [null,str,null];
635
+ if (symbol.ttype == DEFINITION) {
636
+ str = symbol.output+AMremoveCharsAndBlanks(str,symbol.input.length);
637
+ symbol = AMgetSymbol(str);
638
+ if (symbol == null || symbol.ttype == RIGHTBRACKET)
639
+ return [null,str,null];
640
+ }
641
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
642
+ switch (symbol.ttype) {
643
+ case SPACE:
644
+ node = AMcreateElementMathML(symbol.tag);
645
+ node.setAttribute(symbol.atname,symbol.atval);
646
+ return [node,str,symbol.tag];
647
+ case UNDEROVER:
648
+ if (isIE) {
649
+ if (symbol.input.substr(0,4) == "\\big") { // botch for missing symbols
650
+ str = "\\"+symbol.input.substr(4)+str; // make \bigcup = \cup etc.
651
+ symbol = AMgetSymbol(str);
652
+ symbol.ttype = UNDEROVER;
653
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
654
+ }
655
+ }
656
+ return [AMcreateMmlNode(symbol.tag,
657
+ document.createTextNode(symbol.output)),str,symbol.tag];
658
+ case CONST:
659
+ var output = symbol.output;
660
+ if (isIE) {
661
+ if (symbol.input == "'")
662
+ output = "\u2032";
663
+ else if (symbol.input == "''")
664
+ output = "\u2033";
665
+ else if (symbol.input == "'''")
666
+ output = "\u2033\u2032";
667
+ else if (symbol.input == "''''")
668
+ output = "\u2033\u2033";
669
+ else if (symbol.input == "\\square")
670
+ output = "\u25A1"; // same as \Box
671
+ else if (symbol.input.substr(0,5) == "\\frac") {
672
+ // botch for missing fractions
673
+ var denom = symbol.input.substr(6,1);
674
+ if (denom == "5" || denom == "6") {
675
+ str = symbol.input.replace(/\\frac/,"\\frac ")+str;
676
+ return [node,str,symbol.tag];
677
+ }
678
+ }
679
+ }
680
+ node = AMcreateMmlNode(symbol.tag,document.createTextNode(output));
681
+ return [node,str,symbol.tag];
682
+ case LONG: // added by DRW
683
+ node = AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output));
684
+ node.setAttribute("minsize","1.5");
685
+ node.setAttribute("maxsize","1.5");
686
+ node = AMcreateMmlNode("mover",node);
687
+ node.appendChild(AMcreateElementMathML("mspace"));
688
+ return [node,str,symbol.tag];
689
+ case STRETCHY: // added by DRW
690
+ if (isIE && symbol.input == "\\backslash")
691
+ symbol.output = "\\"; // doesn't expand, but then nor does "\u2216"
692
+ node = AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output));
693
+ if (symbol.input == "|" || symbol.input == "\\vert" ||
694
+ symbol.input == "\\|" || symbol.input == "\\Vert") {
695
+ node.setAttribute("lspace","0em");
696
+ node.setAttribute("rspace","0em");
697
+ }
698
+ node.setAttribute("maxsize",symbol.atval); // don't allow to stretch here
699
+ if (symbol.rtag != null)
700
+ return [node,str,symbol.rtag];
701
+ else
702
+ return [node,str,symbol.tag];
703
+ case BIG: // added by DRW
704
+ var atval = symbol.atval;
705
+ if (isIE)
706
+ atval = symbol.ieval;
707
+ symbol = AMgetSymbol(str);
708
+ if (symbol == null)
709
+ return [null,str,null];
710
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
711
+ node = AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output));
712
+ if (isIE) { // to get brackets to expand
713
+ var space = AMcreateElementMathML("mspace");
714
+ space.setAttribute("height",atval+"ex");
715
+ node = AMcreateMmlNode("mrow",node);
716
+ node.appendChild(space);
717
+ } else { // ignored in IE
718
+ node.setAttribute("minsize",atval);
719
+ node.setAttribute("maxsize",atval);
720
+ }
721
+ return [node,str,symbol.tag];
722
+ case LEFTBRACKET: //read (expr+)
723
+ if (symbol.input == "\\left") { // left what?
724
+ symbol = AMgetSymbol(str);
725
+ if (symbol != null) {
726
+ if (symbol.input == ".")
727
+ symbol.invisible = true;
728
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
729
+ }
730
+ }
731
+ result = AMparseExpr(str,true,false);
732
+ if (symbol==null ||
733
+ (typeof symbol.invisible == "boolean" && symbol.invisible))
734
+ node = AMcreateMmlNode("mrow",result[0]);
735
+ else {
736
+ node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
737
+ node = AMcreateMmlNode("mrow",node);
738
+ node.appendChild(result[0]);
739
+ }
740
+ return [node,result[1],result[2]];
741
+ case MATRIX: //read (expr+)
742
+ if (symbol.input == "\\begin{array}") {
743
+ var mask = "";
744
+ symbol = AMgetSymbol(str);
745
+ str = AMremoveCharsAndBlanks(str,0);
746
+ if (symbol == null)
747
+ mask = "l";
748
+ else {
749
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
750
+ if (symbol.input != "{")
751
+ mask = "l";
752
+ else do {
753
+ symbol = AMgetSymbol(str);
754
+ if (symbol != null) {
755
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
756
+ if (symbol.input != "}")
757
+ mask = mask+symbol.input;
758
+ }
759
+ } while (symbol != null && symbol.input != "" && symbol.input != "}");
760
+ }
761
+ result = AMparseExpr("{"+str,true,true);
762
+ // if (result[0]==null) return [AMcreateMmlNode("mo",
763
+ // document.createTextNode(symbol.input)),str];
764
+ node = AMcreateMmlNode("mtable",result[0]);
765
+ mask = mask.replace(/l/g,"left ");
766
+ mask = mask.replace(/r/g,"right ");
767
+ mask = mask.replace(/c/g,"center ");
768
+ node.setAttribute("columnalign",mask);
769
+ node.setAttribute("displaystyle","false");
770
+ if (isIE)
771
+ return [node,result[1],null];
772
+ // trying to get a *little* bit of space around the array
773
+ // (IE already includes it)
774
+ var lspace = AMcreateElementMathML("mspace");
775
+ lspace.setAttribute("width","0.167em");
776
+ var rspace = AMcreateElementMathML("mspace");
777
+ rspace.setAttribute("width","0.167em");
778
+ var node1 = AMcreateMmlNode("mrow",lspace);
779
+ node1.appendChild(node);
780
+ node1.appendChild(rspace);
781
+ return [node1,result[1],null];
782
+ } else { // eqnarray
783
+ result = AMparseExpr("{"+str,true,true);
784
+ node = AMcreateMmlNode("mtable",result[0]);
785
+ if (isIE)
786
+ node.setAttribute("columnspacing","0.25em"); // best in practice?
787
+ else
788
+ node.setAttribute("columnspacing","0.167em"); // correct (but ignored?)
789
+ node.setAttribute("columnalign","right center left");
790
+ node.setAttribute("displaystyle","true");
791
+ node = AMcreateMmlNode("mrow",node);
792
+ return [node,result[1],null];
793
+ }
794
+ case TEXT:
795
+ if (str.charAt(0)=="{") i=str.indexOf("}");
796
+ else i = 0;
797
+ if (i==-1)
798
+ i = str.length;
799
+ st = str.slice(1,i);
800
+ if (st.charAt(0) == " ") {
801
+ node = AMcreateElementMathML("mspace");
802
+ node.setAttribute("width","0.33em"); // was 1ex
803
+ newFrag.appendChild(node);
804
+ }
805
+ newFrag.appendChild(
806
+ AMcreateMmlNode(symbol.tag,document.createTextNode(st)));
807
+ if (st.charAt(st.length-1) == " ") {
808
+ node = AMcreateElementMathML("mspace");
809
+ node.setAttribute("width","0.33em"); // was 1ex
810
+ newFrag.appendChild(node);
811
+ }
812
+ str = AMremoveCharsAndBlanks(str,i+1);
813
+ return [AMcreateMmlNode("mrow",newFrag),str,null];
814
+ case UNARY:
815
+ result = AMparseSexpr(str);
816
+ if (result[0]==null) return [AMcreateMmlNode(symbol.tag,
817
+ document.createTextNode(symbol.output)),str];
818
+ if (typeof symbol.func == "boolean" && symbol.func) { // functions hack
819
+ st = str.charAt(0);
820
+ // if (st=="^" || st=="_" || st=="/" || st=="|" || st==",") {
821
+ if (st=="^" || st=="_" || st==",") {
822
+ return [AMcreateMmlNode(symbol.tag,
823
+ document.createTextNode(symbol.output)),str,symbol.tag];
824
+ } else {
825
+ node = AMcreateMmlNode("mrow",
826
+ AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)));
827
+ if (isIE) {
828
+ var space = AMcreateElementMathML("mspace");
829
+ space.setAttribute("width","0.167em");
830
+ node.appendChild(space);
831
+ }
832
+ node.appendChild(result[0]);
833
+ return [node,result[1],symbol.tag];
834
+ }
835
+ }
836
+ if (symbol.input == "\\sqrt") { // sqrt
837
+ if (isIE) { // set minsize, for \surd
838
+ var space = AMcreateElementMathML("mspace");
839
+ space.setAttribute("height","1.2ex");
840
+ space.setAttribute("width","0em"); // probably no effect
841
+ node = AMcreateMmlNode(symbol.tag,result[0])
842
+ // node.setAttribute("minsize","1"); // ignored
843
+ // node = AMcreateMmlNode("mrow",node); // hopefully unnecessary
844
+ node.appendChild(space);
845
+ return [node,result[1],symbol.tag];
846
+ } else
847
+ return [AMcreateMmlNode(symbol.tag,result[0]),result[1],symbol.tag];
848
+ } else if (typeof symbol.acc == "boolean" && symbol.acc) { // accent
849
+ node = AMcreateMmlNode(symbol.tag,result[0]);
850
+ var output = symbol.output;
851
+ if (isIE) {
852
+ if (symbol.input == "\\hat")
853
+ output = "\u0302";
854
+ else if (symbol.input == "\\widehat")
855
+ output = "\u005E";
856
+ else if (symbol.input == "\\bar")
857
+ output = "\u00AF";
858
+ else if (symbol.input == "\\grave")
859
+ output = "\u0300";
860
+ else if (symbol.input == "\\tilde")
861
+ output = "\u0303";
862
+ }
863
+ var node1 = AMcreateMmlNode("mo",document.createTextNode(output));
864
+ if (symbol.input == "\\vec" || symbol.input == "\\check")
865
+ // don't allow to stretch
866
+ node1.setAttribute("maxsize","1.2");
867
+ // why doesn't "1" work? \vec nearly disappears in firefox
868
+ if (isIE && symbol.input == "\\bar")
869
+ node1.setAttribute("maxsize","0.5");
870
+ if (symbol.input == "\\underbrace" || symbol.input == "\\underline")
871
+ node1.setAttribute("accentunder","true");
872
+ else
873
+ node1.setAttribute("accent","true");
874
+ node.appendChild(node1);
875
+ if (symbol.input == "\\overbrace" || symbol.input == "\\underbrace")
876
+ node.ttype = UNDEROVER;
877
+ return [node,result[1],symbol.tag];
878
+ } else { // font change or displaystyle command
879
+ if (!isIE && typeof symbol.codes != "undefined") {
880
+ for (i=0; i<result[0].childNodes.length; i++)
881
+ if (result[0].childNodes[i].nodeName=="mi" || result[0].nodeName=="mi") {
882
+ st = (result[0].nodeName=="mi"?result[0].firstChild.nodeValue:
883
+ result[0].childNodes[i].firstChild.nodeValue);
884
+ var newst = [];
885
+ for (var j=0; j<st.length; j++)
886
+ if (st.charCodeAt(j)>64 && st.charCodeAt(j)<91) newst = newst +
887
+ String.fromCharCode(symbol.codes[st.charCodeAt(j)-65]);
888
+ else newst = newst + st.charAt(j);
889
+ if (result[0].nodeName=="mi")
890
+ result[0]=AMcreateElementMathML("mo").
891
+ appendChild(document.createTextNode(newst));
892
+ else result[0].replaceChild(AMcreateElementMathML("mo").
893
+ appendChild(document.createTextNode(newst)),result[0].childNodes[i]);
894
+ }
895
+ }
896
+ node = AMcreateMmlNode(symbol.tag,result[0]);
897
+ node.setAttribute(symbol.atname,symbol.atval);
898
+ if (symbol.input == "\\scriptstyle" ||
899
+ symbol.input == "\\scriptscriptstyle")
900
+ node.setAttribute("displaystyle","false");
901
+ return [node,result[1],symbol.tag];
902
+ }
903
+ case BINARY:
904
+ result = AMparseSexpr(str);
905
+ if (result[0]==null) return [AMcreateMmlNode("mo",
906
+ document.createTextNode(symbol.input)),str,null];
907
+ result2 = AMparseSexpr(result[1]);
908
+ if (result2[0]==null) return [AMcreateMmlNode("mo",
909
+ document.createTextNode(symbol.input)),str,null];
910
+ if (symbol.input=="\\root" || symbol.input=="\\stackrel")
911
+ newFrag.appendChild(result2[0]);
912
+ newFrag.appendChild(result[0]);
913
+ if (symbol.input=="\\frac") newFrag.appendChild(result2[0]);
914
+ return [AMcreateMmlNode(symbol.tag,newFrag),result2[1],symbol.tag];
915
+ case INFIX:
916
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
917
+ return [AMcreateMmlNode("mo",document.createTextNode(symbol.output)),
918
+ str,symbol.tag];
919
+ default:
920
+ return [AMcreateMmlNode(symbol.tag, //its a constant
921
+ document.createTextNode(symbol.output)),str,symbol.tag];
922
+ }
923
+ }
924
+
925
+ function AMparseIexpr(str) {
926
+ var symbol, sym1, sym2, node, result, tag, underover;
927
+ str = AMremoveCharsAndBlanks(str,0);
928
+ sym1 = AMgetSymbol(str);
929
+ result = AMparseSexpr(str);
930
+ node = result[0];
931
+ str = result[1];
932
+ tag = result[2];
933
+ symbol = AMgetSymbol(str);
934
+ if (symbol.ttype == INFIX) {
935
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
936
+ result = AMparseSexpr(str);
937
+ if (result[0] == null) // show box in place of missing argument
938
+ result[0] = AMcreateMmlNode("mo",document.createTextNode("\u25A1"));
939
+ str = result[1];
940
+ tag = result[2];
941
+ if (symbol.input == "_" || symbol.input == "^") {
942
+ sym2 = AMgetSymbol(str);
943
+ tag = null; // no space between x^2 and a following sin, cos, etc.
944
+ // This is for \underbrace and \overbrace
945
+ underover = ((sym1.ttype == UNDEROVER) || (node.ttype == UNDEROVER));
946
+ // underover = (sym1.ttype == UNDEROVER);
947
+ if (symbol.input == "_" && sym2.input == "^") {
948
+ str = AMremoveCharsAndBlanks(str,sym2.input.length);
949
+ var res2 = AMparseSexpr(str);
950
+ str = res2[1];
951
+ tag = res2[2]; // leave space between x_1^2 and a following sin etc.
952
+ node = AMcreateMmlNode((underover?"munderover":"msubsup"),node);
953
+ node.appendChild(result[0]);
954
+ node.appendChild(res2[0]);
955
+ } else if (symbol.input == "_") {
956
+ node = AMcreateMmlNode((underover?"munder":"msub"),node);
957
+ node.appendChild(result[0]);
958
+ } else {
959
+ node = AMcreateMmlNode((underover?"mover":"msup"),node);
960
+ node.appendChild(result[0]);
961
+ }
962
+ node = AMcreateMmlNode("mrow",node); // so sum does not stretch
963
+ } else {
964
+ node = AMcreateMmlNode(symbol.tag,node);
965
+ if (symbol.input == "\\atop" || symbol.input == "\\choose")
966
+ node.setAttribute("linethickness","0ex");
967
+ node.appendChild(result[0]);
968
+ if (symbol.input == "\\choose")
969
+ node = AMcreateMmlNode("mfenced",node);
970
+ }
971
+ }
972
+ return [node,str,tag];
973
+ }
974
+
975
+ function AMparseExpr(str,rightbracket,matrix) {
976
+ var symbol, node, result, i, tag,
977
+ newFrag = document.createDocumentFragment();
978
+ do {
979
+ str = AMremoveCharsAndBlanks(str,0);
980
+ result = AMparseIexpr(str);
981
+ node = result[0];
982
+ str = result[1];
983
+ tag = result[2];
984
+ symbol = AMgetSymbol(str);
985
+ if (node!=undefined) {
986
+ if ((tag == "mn" || tag == "mi") && symbol!=null &&
987
+ typeof symbol.func == "boolean" && symbol.func) {
988
+ // Add space before \sin in 2\sin x or x\sin x
989
+ var space = AMcreateElementMathML("mspace");
990
+ space.setAttribute("width","0.167em");
991
+ node = AMcreateMmlNode("mrow",node);
992
+ node.appendChild(space);
993
+ }
994
+ newFrag.appendChild(node);
995
+ }
996
+ } while ((symbol.ttype != RIGHTBRACKET)
997
+ && symbol!=null && symbol.output!="");
998
+ tag = null;
999
+ if (symbol.ttype == RIGHTBRACKET) {
1000
+ if (symbol.input == "\\right") { // right what?
1001
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
1002
+ symbol = AMgetSymbol(str);
1003
+ if (symbol != null && symbol.input == ".")
1004
+ symbol.invisible = true;
1005
+ if (symbol != null)
1006
+ tag = symbol.rtag;
1007
+ }
1008
+ if (symbol!=null)
1009
+ str = AMremoveCharsAndBlanks(str,symbol.input.length); // ready to return
1010
+ var len = newFrag.childNodes.length;
1011
+ if (matrix &&
1012
+ len>0 && newFrag.childNodes[len-1].nodeName == "mrow" && len>1 &&
1013
+ newFrag.childNodes[len-2].nodeName == "mo" &&
1014
+ newFrag.childNodes[len-2].firstChild.nodeValue == "&") { //matrix
1015
+ var pos = []; // positions of ampersands
1016
+ var m = newFrag.childNodes.length;
1017
+ for (i=0; matrix && i<m; i=i+2) {
1018
+ pos[i] = [];
1019
+ node = newFrag.childNodes[i];
1020
+ for (var j=0; j<node.childNodes.length; j++)
1021
+ if (node.childNodes[j].firstChild.nodeValue=="&")
1022
+ pos[i][pos[i].length]=j;
1023
+ }
1024
+ var row, frag, n, k, table = document.createDocumentFragment();
1025
+ for (i=0; i<m; i=i+2) {
1026
+ row = document.createDocumentFragment();
1027
+ frag = document.createDocumentFragment();
1028
+ node = newFrag.firstChild; // <mrow> -&-&...&-&- </mrow>
1029
+ n = node.childNodes.length;
1030
+ k = 0;
1031
+ for (j=0; j<n; j++) {
1032
+ if (typeof pos[i][k] != "undefined" && j==pos[i][k]){
1033
+ node.removeChild(node.firstChild); //remove &
1034
+ row.appendChild(AMcreateMmlNode("mtd",frag));
1035
+ k++;
1036
+ } else frag.appendChild(node.firstChild);
1037
+ }
1038
+ row.appendChild(AMcreateMmlNode("mtd",frag));
1039
+ if (newFrag.childNodes.length>2) {
1040
+ newFrag.removeChild(newFrag.firstChild); //remove <mrow> </mrow>
1041
+ newFrag.removeChild(newFrag.firstChild); //remove <mo>&</mo>
1042
+ }
1043
+ table.appendChild(AMcreateMmlNode("mtr",row));
1044
+ }
1045
+ return [table,str];
1046
+ }
1047
+ if (typeof symbol.invisible != "boolean" || !symbol.invisible) {
1048
+ node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
1049
+ newFrag.appendChild(node);
1050
+ }
1051
+ }
1052
+ return [newFrag,str,tag];
1053
+ }
1054
+
1055
+ function AMparseMath(str) {
1056
+ var result, node = AMcreateElementMathML("mstyle");
1057
+ if (mathcolor != "") node.setAttribute("mathcolor",mathcolor);
1058
+ if (mathfontfamily != "") node.setAttribute("fontfamily",mathfontfamily);
1059
+ node.appendChild(AMparseExpr(str.replace(/^\s+/g,""),false,false)[0]);
1060
+ node = AMcreateMmlNode("math",node);
1061
+ if (showasciiformulaonhover) //fixed by djhsu so newline
1062
+ node.setAttribute("title",str.replace(/\s+/g," "));//does not show in Gecko
1063
+ if (mathfontfamily != "" && (isIE || mathfontfamily != "serif")) {
1064
+ var fnode = AMcreateElementXHTML("font");
1065
+ fnode.setAttribute("face",mathfontfamily);
1066
+ fnode.appendChild(node);
1067
+ return fnode;
1068
+ }
1069
+ return node;
1070
+ }
1071
+
1072
+ function AMstrarr2docFrag(arr, linebreaks) {
1073
+ var newFrag=document.createDocumentFragment();
1074
+ var expr = false;
1075
+ for (var i=0; i<arr.length; i++) {
1076
+ if (expr) newFrag.appendChild(AMparseMath(arr[i]));
1077
+ else {
1078
+ var arri = (linebreaks ? arr[i].split("\n\n") : [arr[i]]);
1079
+ newFrag.appendChild(AMcreateElementXHTML("span").
1080
+ appendChild(document.createTextNode(arri[0])));
1081
+ for (var j=1; j<arri.length; j++) {
1082
+ newFrag.appendChild(AMcreateElementXHTML("p"));
1083
+ newFrag.appendChild(AMcreateElementXHTML("span").
1084
+ appendChild(document.createTextNode(arri[j])));
1085
+ }
1086
+ }
1087
+ expr = !expr;
1088
+ }
1089
+ return newFrag;
1090
+ }
1091
+
1092
+ function AMprocessNodeR(n, linebreaks) {
1093
+ var mtch, str, arr, frg, i;
1094
+ if (n.childNodes.length == 0) {
1095
+ if ((n.nodeType!=8 || linebreaks) &&
1096
+ n.parentNode.nodeName!="form" && n.parentNode.nodeName!="FORM" &&
1097
+ n.parentNode.nodeName!="textarea" && n.parentNode.nodeName!="TEXTAREA" &&
1098
+ n.parentNode.nodeName!="pre" && n.parentNode.nodeName!="PRE") {
1099
+ str = n.nodeValue;
1100
+ if (!(str == null)) {
1101
+ str = str.replace(/\r\n\r\n/g,"\n\n");
1102
+ str = str.replace(/\x20+/g," ");
1103
+ str = str.replace(/\s*\r\n/g," ");
1104
+ // DELIMITERS:
1105
+ mtch = (str.indexOf("\$")==-1 ? false : true);
1106
+ str = str.replace(/([^\\])\$/g,"$1 \$");
1107
+ str = str.replace(/^\$/," \$"); // in case \$ at start of string
1108
+ arr = str.split(" \$");
1109
+ for (i=0; i<arr.length; i++)
1110
+ arr[i]=arr[i].replace(/\\\$/g,"\$");
1111
+ if (arr.length>1 || mtch) {
1112
+ if (checkForMathML) {
1113
+ checkForMathML = false;
1114
+ var nd = AMisMathMLavailable();
1115
+ AMnoMathML = nd != null;
1116
+ if (AMnoMathML && notifyIfNoMathML)
1117
+ if (alertIfNoMathML)
1118
+ alert("To view the ASCIIMathML notation use Internet Explorer 6 +\nMathPlayer (free from www.dessci.com)\n\
1119
+ or Firefox/Mozilla/Netscape");
1120
+ else AMbody.insertBefore(nd,AMbody.childNodes[0]);
1121
+ }
1122
+ if (!AMnoMathML) {
1123
+ frg = AMstrarr2docFrag(arr,n.nodeType==8);
1124
+ var len = frg.childNodes.length;
1125
+ n.parentNode.replaceChild(frg,n);
1126
+ return len-1;
1127
+ } else return 0;
1128
+ }
1129
+ }
1130
+ } else return 0;
1131
+ } else if (n.nodeName!="math") {
1132
+ for (i=0; i<n.childNodes.length; i++)
1133
+ i += AMprocessNodeR(n.childNodes[i], linebreaks);
1134
+ }
1135
+ return 0;
1136
+ }
1137
+
1138
+ function AMprocessNode(n, linebreaks, spanclassAM) {
1139
+ var frag,st;
1140
+ if (spanclassAM!=null) {
1141
+ frag = document.getElementsByTagName("span")
1142
+ for (var i=0;i<frag.length;i++)
1143
+ if (frag[i].className == "AM")
1144
+ AMprocessNodeR(frag[i],linebreaks);
1145
+ } else {
1146
+ try {
1147
+ st = n.innerHTML;
1148
+ } catch(err) {}
1149
+ // DELIMITERS:
1150
+ if (st==null || st.indexOf("\$")!=-1)
1151
+ AMprocessNodeR(n,linebreaks);
1152
+ }
1153
+ if (isIE) { //needed to match size and font of formula to surrounding text
1154
+ frag = document.getElementsByTagName('math');
1155
+ for (var i=0;i<frag.length;i++) frag[i].update()
1156
+ }
1157
+ }
1158
+
1159
+ var AMbody;
1160
+ var AMnoMathML = false, AMtranslated = false;
1161
+
1162
+ function translate(spanclassAM) {
1163
+ if (!AMtranslated) { // run this only once
1164
+ AMtranslated = true;
1165
+ AMinitSymbols();
1166
+ AMbody = document.getElementsByTagName("body")[0];
1167
+ AMprocessNode(AMbody, false, spanclassAM);
1168
+ }
1169
+ }
1170
+
1171
+ if (isIE) { // avoid adding MathPlayer info explicitly to each webpage
1172
+ document.write("<object id=\"mathplayer\"\
1173
+ classid=\"clsid:32F66A20-7614-11D4-BD11-00104BD3F987\"></object>");
1174
+ document.write("<?import namespace=\"m\" implementation=\"#mathplayer\"?>");
1175
+ }
1176
+
1177
+ // GO1.1 Generic onload by Brothercake
1178
+ // http://www.brothercake.com/
1179
+ //onload function (replaces the onload="translate()" in the <body> tag)
1180
+ function generic()
1181
+ {
1182
+ translate();
1183
+ };
1184
+ //setup onload function
1185
+ if(typeof window.addEventListener != 'undefined')
1186
+ {
1187
+ //.. gecko, safari, konqueror and standard
1188
+ window.addEventListener('load', generic, false);
1189
+ }
1190
+ else if(typeof document.addEventListener != 'undefined')
1191
+ {
1192
+ //.. opera 7
1193
+ document.addEventListener('load', generic, false);
1194
+ }
1195
+ else if(typeof window.attachEvent != 'undefined')
1196
+ {
1197
+ //.. win/ie
1198
+ window.attachEvent('onload', generic);
1199
+ }
1200
+ //** remove this condition to degrade older browsers
1201
+ else
1202
+ {
1203
+ //.. mac/ie5 and anything else that gets this far
1204
+ //if there's an existing onload function
1205
+ if(typeof window.onload == 'function')
1206
+ {
1207
+ //store it
1208
+ var existing = onload;
1209
+ //add new onload handler
1210
+ window.onload = function()
1211
+ {
1212
+ //call existing onload function
1213
+ existing();
1214
+ //call generic onload function
1215
+ generic();
1216
+ };
1217
+ }
1218
+ else
1219
+ {
1220
+ //setup onload function
1221
+ window.onload = generic;
1222
+ }
1223
+ }