用mathjax.js 可以轻松解析html中的数学公式,数学公式用$$符号包围。详见官方文档 http://docs.mathjax.org/en/latest/start.html。
测试代码:- <html>
- <head>
-
- <script type="text/x-mathjax-config">
- MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
- </script>
-
- <script type="text/javascript" async
- src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML">
- </script>
-
- </head>
-
- <body>
- <h1>DEMO</h1>
- If
- $$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}.$$
-
-
- </body>
-
- </html>
复制代码
|