为什么 MathML 代码在 one-single HTML 文件中显示不同,但它在 Jsfiddle 上有效? one-single HTML 的 MathJar?

Why does MathML codes appear different on one-single HTML file, but it worked on Jsfiddle? MathJar for one-single HTML?

我从 MathJax 复制了以下 MathML 代码并将其作为 one-single HTML 文件离线粘贴。当我预览页面时,它看起来与原始 MathJax 版本不同。这是 HTML 文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Maths</title>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <msup>
    <mrow>
      <mo>(</mo>
      <munderover>
        <mo>&#x2211;<!-- ∑ --></mo>
        <mrow class="MJX-TeXAtom-ORD">
          <mi>k</mi>
          <mo>=</mo>
          <mn>1</mn>
        </mrow>
        <mi>n</mi>
      </munderover>
      <msub>
        <mi>a</mi>
        <mi>k</mi>
      </msub>
      <msub>
        <mi>b</mi>
        <mi>k</mi>
      </msub>
      <mo>)</mo>
    </mrow>
    <mrow class="MJX-TeXAtom-ORD">
      <mspace width="negativethinmathspace" />
      <mspace width="negativethinmathspace" />
      <mn>2</mn>
    </mrow>
  </msup>
  <mo>&#x2264;<!-- ≤ --></mo>
  <mrow>
    <mo>(</mo>
    <munderover>
      <mo>&#x2211;<!-- ∑ --></mo>
      <mrow class="MJX-TeXAtom-ORD">
        <mi>k</mi>
        <mo>=</mo>
        <mn>1</mn>
      </mrow>
      <mi>n</mi>
    </munderover>
    <msubsup>
      <mi>a</mi>
      <mi>k</mi>
      <mn>2</mn>
    </msubsup>
    <mo>)</mo>
  </mrow>
  <mrow>
    <mo>(</mo>
    <munderover>
      <mo>&#x2211;<!-- ∑ --></mo>
      <mrow class="MJX-TeXAtom-ORD">
        <mi>k</mi>
        <mo>=</mo>
        <mn>1</mn>
      </mrow>
      <mi>n</mi>
    </munderover>
    <msubsup>
      <mi>b</mi>
      <mi>k</mi>
      <mn>2</mn>
    </msubsup>
    <mo>)</mo>
  </mrow>
</math>
</body>
</html>

这是它的呈现方式:

我在 Jsifiddle 上测试过,效果很好。我不明白为什么。检查:http://jsfiddle.net/05cqx9qy/

我该如何解决这个问题?是否可以在 single-file HTML 文档中离线使用 MathML?

我也在 Firefox 和 Safari 中测试过,还是有区别。在 Jsfiddle 上,在所有浏览器中,它都运行良好。怎么只能在 Jsfiddle 上工作,不能在自己的浏览器上工作?

我想为我的 HTML 文件使用 MathJax Javascript 程序和扩展,但它包含许多 Javascript 文件,我不知道是否可以统一所有MathJax Javascript 文件合二为一,然后将所有内容粘贴到我的离线 single-file HTML 文档中。我认为它不能作为一个 HTML 文件使用。我希望我的 HTML 文件是一个文件,并且独立于文件夹、图像(我转换为 base64)和文件。

HTML 呈现不同的原因是因为浏览器引擎中的原生 MathML 支持仅限于 Gecko/Firefox(好)和 WebKit/Safari(好)。 MathJax 将允许您跨浏览器使用 MathML,但您的示例 HTML 不会 在任何地方加载 MathJax。

至于单文件构建,没有正式的方法,但如果您稍微限制功能,MathJax 可以打包到单个 JavaScript 文件中;它目前需要一些 MathJax 知识,但 this experiment 可能会给你一些想法。单文件构建只有在您限制自己使用 SVG 输出时才能工作,因为 HTML-CSS 输出需要字体。

要使 mathjax 达到 运行,您需要一些 javascript。最简单的是

<script type="text/javascript"
   src="http://cdn.mathjax.org/mathjax/latest/MathJax.js">
</script>

<script type="text/javascript">
MathJax.Hub.Config({
  config: ["MMLorHTML.js"],
  jax: ["input/MathML","output/HTML-CSS","output/NativeMML"],
  extensions: ["mml2jax.js","MathMenu.js","MathZoom.js"]
});
</script>

参见http://docs.mathjax.org/en/latest/configuration.html and http://docs.mathjax.org/en/latest/config-files.html

我在您的示例中没有看到任何 javascript。