Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>MathJax TeX to MathML Page</title>
  5. <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  6. <script>
  7. function toMathML(jax,callback) {
  8. var mml;
  9. try {
  10. mml = jax.root.toMathML("");
  11. } catch(err) {
  12. if (!err.restart) {throw err} // an actual error
  13. return MathJax.Callback.After([toMathML,jax,callback],err.restart);
  14. }
  15. MathJax.Callback(callback)(mml);
  16. }
  17. </script>
  18. <script type="text/x-mathjax-config">
  19. MathJax.Hub.Config({
  20. tex2jax: {inlineMath: [["$","$"],["\(","\)"]]}
  21. });
  22. MathJax.Hub.Queue(
  23. function () {
  24. var jax = MathJax.Hub.getAllJax();
  25. for (var i = 0; i < jax.length; i++) {
  26. toMathML(jax[i],function (mml) {
  27. alert(jax[i].originalText + "nn=>nn"+ trim(mml));
  28. });
  29. }
  30. }
  31. );
  32.  
  33. function trim(value){
  34. value = value.replace(/s+/, "");
  35. value = value.replace(/s+$/g, "");
  36. value = value.replace(/n/g, "");
  37. value = value.replace(/r/g, "");
  38. return value;
  39. }
  40.  
  41. </script>
  42. <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full "></script>
  43. </head>
  44. <body>
  45. <p>
  46. When $a ne 0$, there are two solutions to (ax^2 + bx + c = 0) and
  47. they are
  48. $$x = {-b pm sqrt{b^2-4ac} over 2a}.$$
  49. </p>
  50. </body>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement