asciimathdemo.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <html>
  2. <head>
  3. <title>ASCIIMathML.js demo</title>
  4. <script type="text/javascript" src="ASCIIMathML.js"></script>
  5. <script type="text/javascript">
  6. translateOnLoad=false;
  7. function display() {
  8. var str = document.getElementById("inputText").value;
  9. var outnode = document.getElementById("outputNode");
  10. var n = outnode.childNodes.length;
  11. for (var i=0; i<n; i++)
  12. outnode.removeChild(outnode.firstChild);
  13. outnode.appendChild(document.createTextNode(str));
  14. AMprocessNode(outnode);
  15. }
  16. </script>
  17. <style type="text/css">
  18. #menu, #title, #subtitle, #author {text-align: center}
  19. body {font-family: Arial; background-color:beige;}
  20. </style>
  21. </head>
  22. <body onload="display()">
  23. <div id="menu">
  24. | <a href="asciimath.html">Home Page</a> |
  25. <a href="asciimathsyntax.html">Syntax</a> |
  26. <a href="asciimathdemo.html">Try it</a> |
  27. <a href="asciimathcalculator.html">Calculator</a> |
  28. <a href="http://mathcs.chapman.edu/~jipsen/mathml/asciimathdownload.html">Download</a> |
  29. <a href="http://mathcs.chapman.edu/~jipsen/math/index.php/ASCIIMathML/ASCIIMathGraphs.html">Graphs</a> |
  30. <a href="http://mathcs.chapman.edu/~jipsen/math/index.php/ASCIIMathML/ASCIIMathFAQ.html">ASCIIMath FAQ</a> |
  31. <a href="http://mathcs.chapman.edu/~jipsen/math/index.php/ASCIIMathML/ASCIIMathMLSandbox.html">Sandbox</a> |
  32. <a href="http://mathcs.chapman.edu/~jipsen/math/index.php/ASCIIMathML/ASCIIMathCommentsAndSuggestions.html">Comments</a> |
  33. </div>
  34. <hr/>
  35. <h2 id="title">
  36. ASCIIMathML.js: Try it yourself (HTML version)
  37. </h2>
  38. <center>
  39. <b>
  40. This page requires Internet Explorer 6+<a
  41. href="http://www.dessci.com/en/products/mathplayer">MathPlayer</a>
  42. or Mozilla/Firefox/Netscape 7+.
  43. </b>
  44. <p>
  45. Edit the formulas below (the display updates dynamically).
  46. If you know (La)TeX formula syntax, you can try some of that as well
  47. (LaTeX formulas work best when enclosed in $-signs).
  48. The "amath" token switches on the new auto-math-recognize mode.</p>
  49. <form>
  50. <textarea id="inputText" rows="10" cols="80" onkeyup="display()">
  51. amath
  52. Let's try some interesting formulas: E=m c^2
  53. and e^(i pi)=-1
  54. and AA x in CC (sin^2x+cos^2x=1)
  55. and one more: sum_(i=1)^n i^3=((n(n+1))/2)^2
  56. (add your own -- note that text-tokens are only recognized if separated by spaces)
  57. </textarea>
  58. </form>
  59. <p>
  60. <div id="outputNode"></div>
  61. </p>
  62. <hr/>
  63. <p>
  64. <b>Note that this is dynamic XHTML running locally on your machine!</b>
  65. <br>
  66. Right-click on an output formula to copy or view the MathML code.
  67. </p>
  68. </center>
  69. (Copy and paste the following lines to see what symbols they produce)<br/>
  70. <b>You can use the following ASCIIMathML constructs:</b>
  71. <tt> `(x+1)/(x-1) x^(i+j) x_(ij) sqrt(x) root(n)(x) stackrel(+)(->) text(any) "any"`</tt><br/>
  72. <b>Operation symbols</b>
  73. <tt> `+ - * ** // \\ xx -: @ o+ ox sum prod ^^ ^^^ vv vvv nn nnn uu uuu`</tt><br/>
  74. <b>Relation symbols</b>
  75. <tt> `= != &lt; &lt;= > >= -&lt; >- in !in sub sup sube supe -= ~= ~~ prop`</tt><br/>
  76. <b>Logical symbols</b><tt> `\and \or \not => if iff AA EE _|_ TT |-- |==`</tt><br/>
  77. <b>Miscellaneous symbols</b>
  78. <tt> `int oint del grad +- O/ oo aleph ... cdots \ quad qquad diamond square |__ __| |~ ~| CC NN QQ RR ZZ`</tt><br/>
  79. <b>Standard functions</b>
  80. <tt> `sin cos tan csc sec cot sinh cosh tanh log ln det dim lim mod gcd lcm`</tt><br/>
  81. <b>Grouping brackets</b><tt> `( ) [ ] { } (: :) {: :}` </tt>
  82. <b>Arrows</b><tt> `uarr darr rarr -> larr harr rArr lArr hArr` </tt><br/>
  83. <b>Accents</b><tt> `hatx barx ulx vecx dotx ddotx` </tt>
  84. <b>Font commands</b><tt> `bbA bbbA ccA ttA frA sfA` </tt>
  85. <b>Matrices</b><tt> `[[a,b],[c,d]] ((1,0),(0,1))` </tt><br/>
  86. <b>Greek letters</b><tt> `alpha beta chi delta Delta epsi eta gamma Gamma
  87. iota kappa lambda Lambda mu nu omega Omega phi Phi pi Pi psi rho sigma Sigma
  88. tau theta Theta upsilon xi Xi zeta`</tt>
  89. <p>
  90. This demo page shows that ASCIIMathML.js can be used easily to
  91. dynamically preview mathematical formulas (client-side). E.g. here is a
  92. (beta) webpage that can be used to <b><a
  93. href="http://math.chapman.edu/email/">write and read
  94. mathematical emails and discussion group articles</a></b>. Since most
  95. email communication is still done with ASCII text (or at least not yet
  96. with XHTML), this is a reasonable (and inexpensive) solution for
  97. communicating with students in online math courses.
  98. </p>
  99. <hr/>
  100. <div id="author">
  101. <a href="http://www.chapman.edu/~jipsen/">Peter Jipsen</a>,
  102. <a href="http://www.chapman.edu/">Chapman University</a>, September 2007
  103. </div>
  104. </body>
  105. </html>