Gly*_*ard 4 html javascript input mathml mathjax
我正在尝试包含html输入字段,例如:
<input id="txtBox" type="text" size="1" style="text-align: center">
Run Code Online (Sandbox Code Playgroud)
在mathML方程中.当我最初在Firefox上本地创建和测试它们时,一切看起来都很好(本机呈现内容).但是,现在我已将它上传到我们的网站,该网站使用mathjax 2.01呈现内容,我得到的输入框应该是"未知节点类型:输入"错误.我现在把盒子包裹起来
<annotation>
Run Code Online (Sandbox Code Playgroud)
标签,如另一篇文章中所述,但我仍然收到相同的错误.
<script type="math/mml">
<math>
<mstyle displaystyle="true">
<msup>
<mi>x</mi>
<semantics>
<annotation-xml encoding="application/xhtml+xml">
<input xmlns="http://www.w3.org/1999/xhtml" style="text-align:right" type="text" size="2" name="n" /></input>
</annotation-xml>
</semantics>
</msup>
<mo>+</mo>
<semantics>
<annotation-xml encoding="application/xhtml+xml">
<input xmlns="http://www.w3.org/1999/xhtml" type="text" size="2" name="b" /></input>
</annotation-xml>
</semantics>
</mstyle>
</math>
</script>
Run Code Online (Sandbox Code Playgroud)
MathML3.0规范不提供直接嵌入MathML中的HTML元素.HTML5扩展了定义,允许在MathML中的标记元素中使用HTML标记<mtext>,例如.然而,MathJax是在HTML5完成之前开发的,它遵循MathML3.0规范,因此一般不允许使用HTML标记.
但是,可以使用<semantics>和<annotation-xml>元素在MathML中包含HTML.请注意,<annotation>并且<annotation-xml>只能作为子项显示<semantics>,因此您需要两者.此外,<annotation>标记的正文应该是纯文本,而不是HTML标记,因此要包含HTML,您必须使用<annotation-xml>not <annotation>.最后,您需要提供标记的encoding属性<annotation-xml>,并且注释的内容需要一个xmlns属性以确保在popper命名空间中解析它.
以下示例适用于MathJax以及Firefox中的本机MathML:
<script type="math/mml">
<math>
<mstyle displaystyle="true">
<msup>
<mi>x</mi>
<semantics>
<annotation-xml encoding="application/xhtml+xml">
<input xmlns="http://www.w3.org/1999/xhtml" style="text-align:right" type="text" size="2" name="n" />
</annotation-xml>
</semantics>
</msup>
<mo>+</mo>
<semantics>
<annotation-xml encoding="application/xhtml+xml">
<input xmlns="http://www.w3.org/1999/xhtml" type="text" size="2" name="b" />
</annotation-xml>
</semantics>
</mstyle>
</math>
</script>
Run Code Online (Sandbox Code Playgroud)
我们希望改进MathJax未来版本的情况,但现在这是唯一的选择.我希望这对你有用.