ju1ce--
ju1ce--

Reputation: 161

MathJax with XHTML

Apparently MathJax works with XHTML pages, but I cannot seem to get this to work. Does anyone have a sample file with this working? I have a simple example that works in HTML but not when converted to valid XHTML (validated with Oxygen XML Editor).

Upvotes: 0

Views: 247

Answers (1)

ju1ce--
ju1ce--

Reputation: 161

OK I did a bit more paring back of my work and have now crafted a basic sample that seems to render correctly via XHTML in Chrome 74. Case closed, and hope this helps someone else.

EDIT: I would note that the file suffix has to be .xhtml not .xml. If the suffix is .xml then the MathJax does not render. It appears the MIME type of the file must be "application/xhtml+xml" in order for MathJax to work.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>MathJax Test</title>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=MML_CHTML"></script>        
    </head>
    <body>        
        <p>
            Equation below:
            <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
                <mi>x</mi> <mo>=</mo>
                <mrow>
                    <mfrac>
                        <mrow>
                            <mo>&#x2212;</mo>
                            <mi>b</mi>
                            <mo>&#x00B1;</mo>
                            <msqrt>
                                <msup><mi>b</mi><mn>2</mn></msup>
                                <mo>&#x2212;</mo>
                                <mn>4</mn><mi>a</mi><mi>c</mi>
                            </msqrt>
                        </mrow>
                        <mrow> <mn>2</mn><mi>a</mi> </mrow>
                    </mfrac>
                </mrow>
                <mtext>.</mtext>
            </math>
        </p>        
    </body>
</html>

Upvotes: 1

Related Questions