问题
I have a ckeditor where we can create math equation when I am fetch equation from database it look like a+b2
but I want like (a+b)^2
. So, How can I do this? Please help me.
html_entity_decode($post->answer)
I am using html_entity_decode
but it not look exactly I want.
回答1:
Browser support for MathML is still rather patchy, but you can get it working in just about any browser by adding the MathJax library to your web document. Just add the following two lines to your HTML:
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
It should then render correctly. Try running the following snippet for example:
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<p> <math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mfenced><mrow><mi>a</mi><mo>+</mo><mi>b</mi></mrow></mfenced><mn>2</mn></msup><mo>=</mo><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>+</mo><mn>2</mn><mi>a</mi><mi>b</mi></mrow></math></p>
来源:https://stackoverflow.com/questions/64047281/how-to-show-math-equation-in-php-html