Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>MathJax TeX to MathML Page</title>
- <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
- <script>
- function toMathML(jax,callback) {
- var mml;
- try {
- mml = jax.root.toMathML("");
- } catch(err) {
- if (!err.restart) {throw err} // an actual error
- return MathJax.Callback.After([toMathML,jax,callback],err.restart);
- }
- MathJax.Callback(callback)(mml);
- }
- </script>
- <script type="text/x-mathjax-config">
- MathJax.Hub.Config({
- tex2jax: {inlineMath: [["$","$"],["\(","\)"]]}
- });
- MathJax.Hub.Queue(
- function () {
- var jax = MathJax.Hub.getAllJax();
- for (var i = 0; i < jax.length; i++) {
- toMathML(jax[i],function (mml) {
- alert(jax[i].originalText + "nn=>nn"+ trim(mml));
- });
- }
- }
- );
- function trim(value){
- value = value.replace(/s+/, "");
- value = value.replace(/s+$/g, "");
- value = value.replace(/n/g, "");
- value = value.replace(/r/g, "");
- return value;
- }
- </script>
- <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full "></script>
- </head>
- <body>
- <p>
- When $a ne 0$, there are two solutions to (ax^2 + bx + c = 0) and
- they are
- $$x = {-b pm sqrt{b^2-4ac} over 2a}.$$
- </p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement