AMP

amp-mathml

描述

显示 MathML 公式。

 

所需脚本

<script async custom-element="amp-mathml" src="https://cdn.ampproject.org/v0/amp-mathml-0.1.js"></script>

支持的布局

用法

在 iframe 中渲染 MathML 公式。

下面的示例显示二次公式

<amp-mathml
  layout="container"
  data-formula="\[x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\]"
>
</amp-mathml>

下面的示例显示柯西积分公式

<amp-mathml
  layout="container"
  data-formula="\[f(a) = \frac{1}{2\pi i} \oint\frac{f(z)}{z-a}dz\]"
>
</amp-mathml>

下面的示例显示余弦的双角公式

<amp-mathml
  layout="container"
  data-formula="$$ \cos(θ+φ)=\cos(θ)\cos(φ)−\sin(θ)\sin(φ) $$"
>
</amp-mathml>

内联公式

这是一个公式的示例,其中<amp-mathml layout="container" inline data-formula="`x`"></amp-mathml>, <amp-mathml layout="container" inline data-formula="\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)"></amp-mathml>放置在文本块的中间。<amp-mathml layout="container" inline data-formula="\( \cos(θ+φ) \)"></amp-mathml> 这显示了公式将如何适应文本块,并且可以使用 CSS 进行样式设置。

属性

data-formula(必需)

指定要渲染的公式。

inline(可选)

如果指定,组件将内联渲染(CSS 中的 inline-block)。

title(可选)

为组件定义 title 属性以传播到底层 <iframe> 元素。默认值为 "MathML formula"

验证

请参阅 AMP 验证器规范中的 amp-mathml 规则

需要更多帮助?

您已经阅读本文档十几次了,但它并没有真正涵盖您的所有问题?也许其他人也有同感:在 Stack Overflow 上联系他们。

前往 Stack Overflow
发现错误或缺少功能?

AMP 项目强烈鼓励您的参与和贡献!我们希望您能成为我们开源社区的持续参与者,但也欢迎您为特别关注的问题做出一次性贡献。

前往 GitHub