首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MathJax在MathML中呈现MathML输入字段

MathJax在MathML中呈现MathML输入字段
EN

Stack Overflow用户
提问于 2014-01-16 19:30:50
回答 1查看 4.1K关注 0票数 4

我试图包括html输入字段,如:

代码语言:javascript
复制
<input id="txtBox" type="text" size="1" style="text-align: center">

在mathML方程中。当我最初在Firefox上本地创建和测试它们时,一切看起来都很好(本机呈现内容)。但是,现在我已经将它上传到了我们的站点,它使用mathjax 2.01来呈现我得到的“未知节点类型:输入”错误,无论输入框在哪里都应该是这样。我现在把箱子包在里面

代码语言:javascript
复制
 <annotation> 

标签,如在另一篇文章中所描述的,然而,我仍然收到同样的错误。

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-17 20:02:58

MathML3.0规范不提供直接嵌入在MathML中的HTML元素。HTML5扩展了定义,允许在MathML中的令牌元素中使用HTML标记,例如<mtext>。然而,MathJax是在HTML5完成之前开发的,它遵循MathML3.0规范,因此通常不允许使用HTML5标记。

但是,可以使用<semantics><annotation-xml>元素在MathML中包含MathML。请注意,<annotation><annotation-xml>只能作为<semantics>的子级出现,因此两者都需要。另外,<annotation>标记的主体应该是纯文本,而不是HTML标记,因此要包含<annotation-xml>,必须使用<annotation-xml>而不是<annotation>。最后,您需要为encoding标记提供<annotation-xml>属性,注释的内容需要一个xmlns属性,以确保它在<annotation-xml>名称空间中被解析。

下面是一个与MathJax以及火狐中的原生MathML一起工作的示例:

代码语言:javascript
复制
<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>

我们确实希望在未来版本的MathJax中改进这种情况,但现在这是唯一的选择。我希望这对你有用。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21171107

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档