mizuho 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (295) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.markdown +61 -0
  3. data/Rakefile +41 -0
  4. data/asciidoc/BUGS +39 -0
  5. data/asciidoc/BUGS.txt +32 -0
  6. data/asciidoc/CHANGELOG +1796 -0
  7. data/asciidoc/CHANGELOG.txt +1810 -0
  8. data/asciidoc/COPYING +339 -0
  9. data/asciidoc/COPYRIGHT +18 -0
  10. data/asciidoc/INSTALL +76 -0
  11. data/asciidoc/INSTALL.txt +71 -0
  12. data/asciidoc/Makefile.in +161 -0
  13. data/asciidoc/README +46 -0
  14. data/asciidoc/README.txt +36 -0
  15. data/asciidoc/a2x +674 -0
  16. data/asciidoc/asciidoc.conf +455 -0
  17. data/asciidoc/asciidoc.py +4998 -0
  18. data/asciidoc/common.aap +9 -0
  19. data/asciidoc/configure +2840 -0
  20. data/asciidoc/configure.ac +11 -0
  21. data/asciidoc/dblatex/asciidoc-dblatex.sty +20 -0
  22. data/asciidoc/dblatex/asciidoc-dblatex.xsl +32 -0
  23. data/asciidoc/dblatex/dblatex-readme.txt +39 -0
  24. data/asciidoc/doc/a2x.1 +257 -0
  25. data/asciidoc/doc/a2x.1.txt +204 -0
  26. data/asciidoc/doc/article.css-embedded.html +602 -0
  27. data/asciidoc/doc/article.html +46 -0
  28. data/asciidoc/doc/article.pdf +0 -0
  29. data/asciidoc/doc/article.txt +122 -0
  30. data/asciidoc/doc/asciidoc-revhistory.xml +27 -0
  31. data/asciidoc/doc/asciidoc.1 +155 -0
  32. data/asciidoc/doc/asciidoc.1.css-embedded.html +598 -0
  33. data/asciidoc/doc/asciidoc.1.css.html +212 -0
  34. data/asciidoc/doc/asciidoc.1.html +190 -0
  35. data/asciidoc/doc/asciidoc.1.txt +118 -0
  36. data/asciidoc/doc/asciidoc.conf +8 -0
  37. data/asciidoc/doc/asciidoc.css-embedded.html +7853 -0
  38. data/asciidoc/doc/asciidoc.css.html +7416 -0
  39. data/asciidoc/doc/asciidoc.dict +733 -0
  40. data/asciidoc/doc/asciidoc.html +3339 -0
  41. data/asciidoc/doc/asciidoc.txt +4979 -0
  42. data/asciidoc/doc/asciimathml.txt +64 -0
  43. data/asciidoc/doc/book-multi.css-embedded.html +575 -0
  44. data/asciidoc/doc/book-multi.html +55 -0
  45. data/asciidoc/doc/book-multi.txt +155 -0
  46. data/asciidoc/doc/book.css-embedded.html +607 -0
  47. data/asciidoc/doc/book.html +43 -0
  48. data/asciidoc/doc/book.txt +131 -0
  49. data/asciidoc/doc/customers.csv +18 -0
  50. data/asciidoc/doc/docbook-xsl.css +272 -0
  51. data/asciidoc/doc/faq.txt +547 -0
  52. data/asciidoc/doc/latex-backend.html +117 -0
  53. data/asciidoc/doc/latex-backend.txt +191 -0
  54. data/asciidoc/doc/latexmath.txt +244 -0
  55. data/asciidoc/doc/latexmathml.txt +41 -0
  56. data/asciidoc/doc/main.aap +297 -0
  57. data/asciidoc/doc/music-filter.html +566 -0
  58. data/asciidoc/doc/music-filter.pdf +0 -0
  59. data/asciidoc/doc/music-filter.txt +158 -0
  60. data/asciidoc/doc/source-highlight-filter.html +214 -0
  61. data/asciidoc/doc/source-highlight-filter.pdf +0 -0
  62. data/asciidoc/doc/source-highlight-filter.txt +203 -0
  63. data/asciidoc/docbook-xsl/asciidoc-docbook-xsl.txt +43 -0
  64. data/asciidoc/docbook-xsl/chunked.xsl +19 -0
  65. data/asciidoc/docbook-xsl/common.xsl +67 -0
  66. data/asciidoc/docbook-xsl/fo.xsl +149 -0
  67. data/asciidoc/docbook-xsl/htmlhelp.xsl +17 -0
  68. data/asciidoc/docbook-xsl/manpage.xsl +31 -0
  69. data/asciidoc/docbook-xsl/text.xsl +50 -0
  70. data/asciidoc/docbook-xsl/xhtml.xsl +14 -0
  71. data/asciidoc/docbook.conf +721 -0
  72. data/asciidoc/examples/website/ASCIIMathML.js +938 -0
  73. data/asciidoc/examples/website/CHANGELOG.html +4389 -0
  74. data/asciidoc/examples/website/CHANGELOG.txt +1810 -0
  75. data/asciidoc/examples/website/INSTALL.html +161 -0
  76. data/asciidoc/examples/website/INSTALL.txt +71 -0
  77. data/asciidoc/examples/website/LaTeXMathML.js +1223 -0
  78. data/asciidoc/examples/website/README-website.html +118 -0
  79. data/asciidoc/examples/website/README-website.txt +29 -0
  80. data/asciidoc/examples/website/README.html +125 -0
  81. data/asciidoc/examples/website/README.txt +36 -0
  82. data/asciidoc/examples/website/a2x.1.html +419 -0
  83. data/asciidoc/examples/website/a2x.1.txt +204 -0
  84. data/asciidoc/examples/website/asciidoc-docbook-xsl.html +130 -0
  85. data/asciidoc/examples/website/asciidoc-docbook-xsl.txt +43 -0
  86. data/asciidoc/examples/website/asciidoc-graphviz-sample.txt +130 -0
  87. data/asciidoc/examples/website/asciimathml.txt +64 -0
  88. data/asciidoc/examples/website/build-website.sh +25 -0
  89. data/asciidoc/examples/website/customers.csv +18 -0
  90. data/asciidoc/examples/website/downloads.html +257 -0
  91. data/asciidoc/examples/website/downloads.txt +121 -0
  92. data/asciidoc/examples/website/faq.html +673 -0
  93. data/asciidoc/examples/website/faq.txt +547 -0
  94. data/asciidoc/examples/website/index.html +419 -0
  95. data/asciidoc/examples/website/index.txt +245 -0
  96. data/asciidoc/examples/website/latex-backend.html +535 -0
  97. data/asciidoc/examples/website/latex-backend.txt +191 -0
  98. data/asciidoc/examples/website/latexmathml.txt +41 -0
  99. data/asciidoc/examples/website/layout1.conf +161 -0
  100. data/asciidoc/examples/website/layout1.css +65 -0
  101. data/asciidoc/examples/website/layout2.conf +158 -0
  102. data/asciidoc/examples/website/layout2.css +93 -0
  103. data/asciidoc/examples/website/manpage.html +266 -0
  104. data/asciidoc/examples/website/manpage.txt +118 -0
  105. data/asciidoc/examples/website/music-filter.html +242 -0
  106. data/asciidoc/examples/website/music-filter.txt +158 -0
  107. data/asciidoc/examples/website/music1.abc +12 -0
  108. data/asciidoc/examples/website/music1.png +0 -0
  109. data/asciidoc/examples/website/music2.ly +9 -0
  110. data/asciidoc/examples/website/music2.png +0 -0
  111. data/asciidoc/examples/website/newlists.txt +40 -0
  112. data/asciidoc/examples/website/newtables.txt +397 -0
  113. data/asciidoc/examples/website/sample1.png +0 -0
  114. data/asciidoc/examples/website/sample3.png +0 -0
  115. data/asciidoc/examples/website/sample4.png +0 -0
  116. data/asciidoc/examples/website/source-highlight-filter.html +286 -0
  117. data/asciidoc/examples/website/source-highlight-filter.txt +203 -0
  118. data/asciidoc/examples/website/support.html +78 -0
  119. data/asciidoc/examples/website/support.txt +5 -0
  120. data/asciidoc/examples/website/toc.js +69 -0
  121. data/asciidoc/examples/website/userguide.html +7460 -0
  122. data/asciidoc/examples/website/userguide.txt +4979 -0
  123. data/asciidoc/examples/website/version83.txt +37 -0
  124. data/asciidoc/examples/website/version9.html +143 -0
  125. data/asciidoc/examples/website/version9.txt +48 -0
  126. data/asciidoc/examples/website/xhtml11-manpage.css +18 -0
  127. data/asciidoc/examples/website/xhtml11-quirks.css +41 -0
  128. data/asciidoc/examples/website/xhtml11.css +328 -0
  129. data/asciidoc/filters/code/code-filter-readme.txt +37 -0
  130. data/asciidoc/filters/code/code-filter-test.txt +15 -0
  131. data/asciidoc/filters/code/code-filter.conf +8 -0
  132. data/asciidoc/filters/code/code-filter.py +239 -0
  133. data/asciidoc/filters/graphviz/asciidoc-graphviz-sample.txt +130 -0
  134. data/asciidoc/filters/graphviz/graphviz-filter.conf +39 -0
  135. data/asciidoc/filters/graphviz/graphviz2png.py +154 -0
  136. data/asciidoc/filters/music/music-filter-test.txt +40 -0
  137. data/asciidoc/filters/music/music-filter.conf +40 -0
  138. data/asciidoc/filters/music/music2png.py +189 -0
  139. data/asciidoc/filters/source/source-highlight-filter-test.txt +19 -0
  140. data/asciidoc/filters/source/source-highlight-filter.conf +108 -0
  141. data/asciidoc/help.conf +213 -0
  142. data/asciidoc/html4.conf +460 -0
  143. data/asciidoc/images/highlighter.png +0 -0
  144. data/asciidoc/images/icons/README +5 -0
  145. data/asciidoc/images/icons/callouts/1.png +0 -0
  146. data/asciidoc/images/icons/callouts/10.png +0 -0
  147. data/asciidoc/images/icons/callouts/11.png +0 -0
  148. data/asciidoc/images/icons/callouts/12.png +0 -0
  149. data/asciidoc/images/icons/callouts/13.png +0 -0
  150. data/asciidoc/images/icons/callouts/14.png +0 -0
  151. data/asciidoc/images/icons/callouts/15.png +0 -0
  152. data/asciidoc/images/icons/callouts/2.png +0 -0
  153. data/asciidoc/images/icons/callouts/3.png +0 -0
  154. data/asciidoc/images/icons/callouts/4.png +0 -0
  155. data/asciidoc/images/icons/callouts/5.png +0 -0
  156. data/asciidoc/images/icons/callouts/6.png +0 -0
  157. data/asciidoc/images/icons/callouts/7.png +0 -0
  158. data/asciidoc/images/icons/callouts/8.png +0 -0
  159. data/asciidoc/images/icons/callouts/9.png +0 -0
  160. data/asciidoc/images/icons/caution.png +0 -0
  161. data/asciidoc/images/icons/example.png +0 -0
  162. data/asciidoc/images/icons/home.png +0 -0
  163. data/asciidoc/images/icons/important.png +0 -0
  164. data/asciidoc/images/icons/next.png +0 -0
  165. data/asciidoc/images/icons/note.png +0 -0
  166. data/asciidoc/images/icons/prev.png +0 -0
  167. data/asciidoc/images/icons/tip.png +0 -0
  168. data/asciidoc/images/icons/up.png +0 -0
  169. data/asciidoc/images/icons/warning.png +0 -0
  170. data/asciidoc/images/smallnew.png +0 -0
  171. data/asciidoc/images/tiger.png +0 -0
  172. data/asciidoc/install-sh +201 -0
  173. data/asciidoc/javascripts/ASCIIMathML.js +938 -0
  174. data/asciidoc/javascripts/LaTeXMathML.js +1223 -0
  175. data/asciidoc/javascripts/toc.js +69 -0
  176. data/asciidoc/lang-es.conf +15 -0
  177. data/asciidoc/latex.conf +663 -0
  178. data/asciidoc/stylesheets/docbook-xsl.css +272 -0
  179. data/asciidoc/stylesheets/xhtml11-manpage.css +18 -0
  180. data/asciidoc/stylesheets/xhtml11-quirks.css +41 -0
  181. data/asciidoc/stylesheets/xhtml11.css +328 -0
  182. data/asciidoc/text.conf +16 -0
  183. data/asciidoc/vim/ftdetect/asciidoc_filetype.vim +53 -0
  184. data/asciidoc/vim/syntax/asciidoc.vim +165 -0
  185. data/asciidoc/wordpress.conf +48 -0
  186. data/asciidoc/xhtml11-quirks.conf +57 -0
  187. data/asciidoc/xhtml11.conf +645 -0
  188. data/bin/mizuho +47 -0
  189. data/bin/mizuho-asciidoc +4 -0
  190. data/lib/mizuho.rb +10 -0
  191. data/lib/mizuho/chapter.rb +54 -0
  192. data/lib/mizuho/generator.rb +134 -0
  193. data/lib/mizuho/heading.rb +46 -0
  194. data/lib/mizuho/parser.rb +103 -0
  195. data/lib/mizuho/source_highlight.rb +2 -0
  196. data/lib/mizuho/template.rb +50 -0
  197. data/source-highlight/ada.lang +38 -0
  198. data/source-highlight/bib.lang +6 -0
  199. data/source-highlight/bison.lang +3 -0
  200. data/source-highlight/c.lang +41 -0
  201. data/source-highlight/c_comment.lang +27 -0
  202. data/source-highlight/c_string.lang +9 -0
  203. data/source-highlight/caml.lang +16 -0
  204. data/source-highlight/changelog.lang +8 -0
  205. data/source-highlight/clike_vardeclaration.lang +4 -0
  206. data/source-highlight/cpp.lang +15 -0
  207. data/source-highlight/csharp.lang +36 -0
  208. data/source-highlight/css.lang +14 -0
  209. data/source-highlight/css_common.outlang +26 -0
  210. data/source-highlight/darwin/source-highlight +0 -0
  211. data/source-highlight/default.css +51 -0
  212. data/source-highlight/default.lang +8 -0
  213. data/source-highlight/default.style +57 -0
  214. data/source-highlight/desktop.lang +7 -0
  215. data/source-highlight/diff.lang +32 -0
  216. data/source-highlight/docbook.outlang +36 -0
  217. data/source-highlight/esc.outlang +46 -0
  218. data/source-highlight/esc.style +35 -0
  219. data/source-highlight/extreme_comment.lang +5 -0
  220. data/source-highlight/extreme_comment2.lang +5 -0
  221. data/source-highlight/extreme_comment3.lang +15 -0
  222. data/source-highlight/fixed-fortran.lang +5 -0
  223. data/source-highlight/flex.lang +37 -0
  224. data/source-highlight/fortran.lang +57 -0
  225. data/source-highlight/function.lang +2 -0
  226. data/source-highlight/glsl.lang +86 -0
  227. data/source-highlight/haxe.lang +7 -0
  228. data/source-highlight/html.lang +7 -0
  229. data/source-highlight/html.outlang +25 -0
  230. data/source-highlight/html_common.outlang +35 -0
  231. data/source-highlight/html_notfixed.outlang +22 -0
  232. data/source-highlight/html_ref.outlang +6 -0
  233. data/source-highlight/htmlcss.outlang +28 -0
  234. data/source-highlight/htmltable.outlang +14 -0
  235. data/source-highlight/htmltablelinenum.outlang +26 -0
  236. data/source-highlight/java.lang +26 -0
  237. data/source-highlight/javadoc.outlang +24 -0
  238. data/source-highlight/javascript.lang +27 -0
  239. data/source-highlight/key_string.lang +4 -0
  240. data/source-highlight/lang.map +108 -0
  241. data/source-highlight/langdef.lang +21 -0
  242. data/source-highlight/latex.lang +52 -0
  243. data/source-highlight/latex.outlang +59 -0
  244. data/source-highlight/latexcolor.outlang +44 -0
  245. data/source-highlight/ldap.lang +10 -0
  246. data/source-highlight/log.lang +53 -0
  247. data/source-highlight/logtalk.lang +85 -0
  248. data/source-highlight/lsm.lang +7 -0
  249. data/source-highlight/lua.lang +27 -0
  250. data/source-highlight/m4.lang +27 -0
  251. data/source-highlight/makefile.lang +42 -0
  252. data/source-highlight/nohilite.lang +2 -0
  253. data/source-highlight/number.lang +3 -0
  254. data/source-highlight/outlang.lang +16 -0
  255. data/source-highlight/outlang.map +12 -0
  256. data/source-highlight/pascal.lang +20 -0
  257. data/source-highlight/perl.lang +134 -0
  258. data/source-highlight/php.lang +25 -0
  259. data/source-highlight/postscript.lang +42 -0
  260. data/source-highlight/prolog.lang +37 -0
  261. data/source-highlight/properties.lang +7 -0
  262. data/source-highlight/python.lang +26 -0
  263. data/source-highlight/ruby.lang +32 -0
  264. data/source-highlight/scala.lang +31 -0
  265. data/source-highlight/script_comment.lang +3 -0
  266. data/source-highlight/sh.lang +38 -0
  267. data/source-highlight/slang.lang +25 -0
  268. data/source-highlight/sml.lang +5 -0
  269. data/source-highlight/source-highlight +24 -0
  270. data/source-highlight/spec.lang +12 -0
  271. data/source-highlight/sql.lang +46 -0
  272. data/source-highlight/style.defaults +15 -0
  273. data/source-highlight/style.lang +16 -0
  274. data/source-highlight/style2.style +10 -0
  275. data/source-highlight/style3.style +10 -0
  276. data/source-highlight/symbols.lang +2 -0
  277. data/source-highlight/tcl.lang +35 -0
  278. data/source-highlight/texinfo.outlang +34 -0
  279. data/source-highlight/texinfo.style +20 -0
  280. data/source-highlight/url.lang +3 -0
  281. data/source-highlight/xhtml.outlang +25 -0
  282. data/source-highlight/xhtml_common.outlang +8 -0
  283. data/source-highlight/xhtml_notfixed.outlang +16 -0
  284. data/source-highlight/xhtmlcss.outlang +19 -0
  285. data/source-highlight/xhtmltable.outlang +7 -0
  286. data/source-highlight/xml.lang +17 -0
  287. data/source-highlight/xorg.lang +10 -0
  288. data/templates/asciidoc.css +358 -0
  289. data/templates/asciidoc.html.erb +86 -0
  290. data/templates/manualsonrails.css +165 -0
  291. data/templates/manualsonrails.html.erb +97 -0
  292. data/test/generator_spec.rb +60 -0
  293. data/test/parser_spec.rb +239 -0
  294. data/test/spec_helper.rb +51 -0
  295. metadata +358 -0
@@ -0,0 +1,161 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
+ <meta name="generator" content="AsciiDoc 8.3.3" />
7
+ <link rel="stylesheet" href="./xhtml11.css" type="text/css" />
8
+ <link rel="stylesheet" href="./xhtml11-quirks.css" type="text/css" />
9
+ <link rel="stylesheet" href="./layout1.css" type="text/css" />
10
+ <script type="text/javascript">
11
+ /*<![CDATA[*/
12
+ window.onload = function(){generateToc(1)}
13
+ /*]]>*/
14
+ </script>
15
+ <script type="text/javascript" src="./toc.js"></script>
16
+ <title>AsciiDoc Installation</title>
17
+ </head>
18
+ <body>
19
+ <div id="layout-banner">
20
+ <div id="layout-title">AsciiDoc</div>
21
+ <div id="layout-description">Text based document generation</div>
22
+ </div>
23
+ <table>
24
+ <tr valign="top">
25
+ <td id="layout-menu">
26
+ <div>&#187;<a href="index.html">Home</a></div>
27
+ <div>&#187;<a href="manpage.html">Man&nbsp;Page</a></div>
28
+ <div>&#187;<a href="userguide.html">User&nbsp;Guide</a></div>
29
+ <div>&#187;<a href="http://powerman.name/doc/asciidoc">Cheatsheet</a></div>
30
+ <div>&#187;<a href="a2x.1.html">a2x</a></div>
31
+ <div>&#187;<a href="README.html">README</a></div>
32
+ <div>&#187;<a href="CHANGELOG.html">ChangeLog</a></div>
33
+ <div>&#187;<a href="INSTALL.html">Installation</a></div>
34
+ <div>&#187;<a href="downloads.html">Downloads</a></div>
35
+ <div>&#187;<a href="faq.html">FAQ</a></div>
36
+ <div>&#187;<a href="support.html">Support</a></div>
37
+ <div id="page-source">&#187;<a href="INSTALL.txt">Page&nbsp;Source</a></div>
38
+ </td>
39
+ <td>
40
+ <div id="layout-content">
41
+ <div id="header">
42
+ <h1>AsciiDoc Installation</h1>
43
+ </div>
44
+ <div id="toc">
45
+ <div id="toctitle">Table of Contents</div>
46
+ <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
47
+ </div>
48
+ <div id="preamble">
49
+ <div class="sectionbody">
50
+ <div class="admonitionblock">
51
+ <table><tr>
52
+ <td class="icon">
53
+ <img src="./images/icons/note.png" alt="Note" />
54
+ </td>
55
+ <td class="content">The current version of <em>AsciiDoc</em> requires <strong>Python 2.4 or newer</strong>
56
+ to run. If you don&#8217;t already have an up-to-date version of Python
57
+ installed it can be downloaded from the official Python website
58
+ <a href="http://www.python.org/">http://www.python.org/</a>.</td>
59
+ </tr></table>
60
+ </div>
61
+ <div class="paragraph"><p>The latest <em>AsciiDoc</em> downloads can be found on the <em>AsciiDoc</em> website
62
+ <a href="http://www.methods.co.nz/asciidoc/downloads.html">http://www.methods.co.nz/asciidoc/downloads.html</a> and at the
63
+ SourceForge <a href="http://sourceforge.net/projects/asciidoc/">http://sourceforge.net/projects/asciidoc/</a>.</p></div>
64
+ </div>
65
+ </div>
66
+ <h2 id="_prepackaged_asciidoc_installation">Prepackaged AsciiDoc installation</h2>
67
+ <div class="sectionbody">
68
+ <div class="paragraph"><p>The <em>AsciiDoc</em>
69
+ <a href="http://www.methods.co.nz/asciidoc/downloads.html">downloads page</a>
70
+ lists <em>AsciiDoc</em> packages for various Linux distributions.</p></div>
71
+ </div>
72
+ <h2 id="_distribution_tarball_installation">Distribution tarball installation</h2>
73
+ <div class="sectionbody">
74
+ <div class="paragraph"><p>If your flavor or UNIX or Linux does not have a packaged <em>AsciiDoc</em>
75
+ distribution or if you prefer to install the latest <em>AsciiDoc</em> version
76
+ from source use the <tt>configure</tt> shell script in the tarball root
77
+ directory.</p></div>
78
+ <div class="paragraph"><p>The <tt>autoconf(1)</tt> generated <tt>configure</tt> script creates a make file
79
+ that is tailored for your system. To install:</p></div>
80
+ <div class="literalblock">
81
+ <div class="content">
82
+ <pre><tt>$ tar -xzf asciidoc-8.3.3.tar.gz
83
+ $ cd asciidoc-8.3.3
84
+ $ ./configure
85
+ $ make
86
+ $ sudo make install</tt></pre>
87
+ </div></div>
88
+ <div class="paragraph"><p>To install the documentation:</p></div>
89
+ <div class="literalblock">
90
+ <div class="content">
91
+ <pre><tt>$ sudo make docs</tt></pre>
92
+ </div></div>
93
+ <div class="paragraph"><p>To uninstall <em>AsciiDoc</em>:</p></div>
94
+ <div class="literalblock">
95
+ <div class="content">
96
+ <pre><tt>$ sudo make uninstall</tt></pre>
97
+ </div></div>
98
+ <div class="paragraph"><p>If Vim is installed on your system the <em>AsciiDoc</em> Vim syntax highlighter
99
+ and filetype detection scripts will be install in the global Vim
100
+ configuration file directory (<tt>asciidoc.vim</tt> in the <tt>syntax</tt> directory
101
+ and <tt>asciidoc_filetype.vim</tt> in the <tt>ftdetect</tt> directory).</p></div>
102
+ </div>
103
+ <h2 id="_microsoft_windows_installation">Microsoft Windows installation</h2>
104
+ <div class="sectionbody">
105
+ <div class="paragraph"><p>To install the zip formatted distribution just unzip the contents to a
106
+ new folder:</p></div>
107
+ <div class="literalblock">
108
+ <div class="content">
109
+ <pre><tt>$ mkdir asciidoc
110
+ $ cd asciidoc
111
+ $ unzip ../asciidoc-8.3.3.zip</tt></pre>
112
+ </div></div>
113
+ </div>
114
+ <h2 id="_testing_your_installation">Testing your installation</h2>
115
+ <div class="sectionbody">
116
+ <div class="paragraph"><p>Test out asciidoc by changing to the <em>AsciiDoc</em> application directory
117
+ and convert the User Guide document (<tt>./doc/asciidoc.txt</tt>) to XHTML
118
+ (<tt>./doc/asciidoc.html</tt>):</p></div>
119
+ <div class="literalblock">
120
+ <div class="content">
121
+ <pre><tt>$ asciidoc doc/asciidoc.txt</tt></pre>
122
+ </div></div>
123
+ <div class="admonitionblock">
124
+ <table><tr>
125
+ <td class="icon">
126
+ <img src="./images/icons/note.png" alt="Note" />
127
+ </td>
128
+ <td class="content">Windows users will need to execute the <tt>asciidoc.py</tt> script
129
+ directly or create a suitable <tt>asciidoc.bat</tt> file.</td>
130
+ </tr></table>
131
+ </div>
132
+ </div>
133
+ <div id="footer">
134
+ <div id="footer-text">
135
+ Version 8.3.3<br />
136
+ Last updated 2009-01-02 11:18:50 NZDT
137
+ </div>
138
+ <div id="footer-badges">
139
+ <a href="http://validator.w3.org/check?uri=referer">
140
+ <img style="border:none; width:88px; height:31px;"
141
+ src="http://www.w3.org/Icons/valid-xhtml11"
142
+ alt="Valid XHTML 1.1!" />
143
+ </a>
144
+ <a href="http://jigsaw.w3.org/css-validator/check/referer">
145
+ <img style="border:none; width:88px; height:31px;"
146
+ src="http://jigsaw.w3.org/css-validator/images/vcss"
147
+ alt="Valid CSS!" />
148
+ </a>
149
+ <a href="http://www.mozilla.org/products/firefox/">
150
+ <img style="border:none; width:110px; height:32px;"
151
+ src="http://www.spreadfirefox.com/community/images/affiliates/Buttons/110x32/safer.gif"
152
+ alt="Get Firefox!" />
153
+ </a>
154
+ </div>
155
+ </div>
156
+ </div>
157
+ </td>
158
+ </tr>
159
+ </table>
160
+ </body>
161
+ </html>
@@ -0,0 +1,71 @@
1
+ AsciiDoc Installation
2
+ =====================
3
+
4
+ NOTE: The current version of AsciiDoc requires *Python 2.4 or newer*
5
+ to run. If you don't already have an up-to-date version of Python
6
+ installed it can be downloaded from the official Python website
7
+ http://www.python.org/.
8
+
9
+ The latest AsciiDoc downloads can be found on the AsciiDoc website
10
+ http://www.methods.co.nz/asciidoc/downloads.html and at the
11
+ SourceForge http://sourceforge.net/projects/asciidoc/.
12
+
13
+ Prepackaged AsciiDoc installation
14
+ ---------------------------------
15
+ The AsciiDoc
16
+ http://www.methods.co.nz/asciidoc/downloads.html[downloads page]
17
+ lists AsciiDoc packages for various Linux distributions.
18
+
19
+
20
+ Distribution tarball installation
21
+ ---------------------------------
22
+ If your flavor or UNIX or Linux does not have a packaged AsciiDoc
23
+ distribution or if you prefer to install the latest AsciiDoc version
24
+ from source use the `configure` shell script in the tarball root
25
+ directory.
26
+
27
+ The `autoconf(1)` generated `configure` script creates a make file
28
+ that is tailored for your system. To install:
29
+
30
+ [subs="attributes"]
31
+ $ tar -xzf asciidoc-{revision}.tar.gz
32
+ $ cd asciidoc-{revision}
33
+ $ ./configure
34
+ $ make
35
+ $ sudo make install
36
+
37
+ To install the documentation:
38
+
39
+ $ sudo make docs
40
+
41
+ To uninstall AsciiDoc:
42
+
43
+ $ sudo make uninstall
44
+
45
+ If Vim is installed on your system the AsciiDoc Vim syntax highlighter
46
+ and filetype detection scripts will be install in the global Vim
47
+ configuration file directory (`asciidoc.vim` in the `syntax` directory
48
+ and `asciidoc_filetype.vim` in the `ftdetect` directory).
49
+
50
+
51
+ Microsoft Windows installation
52
+ ------------------------------
53
+ To install the zip formatted distribution just unzip the contents to a
54
+ new folder:
55
+
56
+ [subs="attributes"]
57
+ $ mkdir asciidoc
58
+ $ cd asciidoc
59
+ $ unzip ../asciidoc-{revision}.zip
60
+
61
+
62
+ Testing your installation
63
+ -------------------------
64
+ Test out asciidoc by changing to the AsciiDoc application directory
65
+ and convert the User Guide document (`./doc/asciidoc.txt`) to XHTML
66
+ (`./doc/asciidoc.html`):
67
+
68
+ $ asciidoc doc/asciidoc.txt
69
+
70
+ NOTE: Windows users will need to execute the `asciidoc.py` script
71
+ directly or create a suitable `asciidoc.bat` file.
@@ -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
+ }