Amp html 我们如何在AMP网站中实现MathJax

Amp html 我们如何在AMP网站中实现MathJax,amp-html,mathjax,Amp Html,Mathjax,我们能在AMP网站上使用MathJax吗。因为我们有很多需要MathJax.js的数学内容。如果是,我们如何实施它?将此包含在head中 <script async custom-element="amp-mathml" src="https://cdn.ampproject.org/v0/amp-mathml-0.1.js"></script> 包括在正文中 <amp-mathml layout="container" data-formula=

我们能在AMP网站上使用MathJax吗。因为我们有很多需要MathJax.js的数学内容。如果是,我们如何实施它?

将此包含在head中


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

包括在正文中



  <amp-mathml layout="container" data-formula="`<%= yourMathjax %>`">
      </amp-mathml>


. 我们使用ejs作为模板引擎

我的页面上有许多示例:

二次公式

我在网上看到了这篇文章。在这里,有一句话是“我已经知道如何使用JavaScript使用MathJax呈现公式——我的挑战是构建一个运行此代码并内联显示的AMP组件。-Adam Silverstein”。这将引导你达到我认为对你有帮助的目标。
<div class="math-header">The Quadratic Formula</div>
<amp-mathml layout="container" data-formula="\[x = {-b \pm \sqrt{b^2-4ac} \over 2a}\]"></amp-mathml>
<div class="math-header">Cauchy's Integral Formula</div>
<amp-mathml layout="container" data-formula="\[f(a) = \frac{1}{2\pi i} \oint _γ \frac{f(z)}{z-a}dz\]"></amp-mathml>
<div class="math-header">Double angle formula for Cosines</div>
<amp-mathml layout="container" data-formula="$$ \cos(θ+φ)=\cos(θ)\cos(φ)−\sin(θ)\sin(φ) $$"></amp-mathml>
<div class="math-header">Gauss' Divergence Theorem</div>
<amp-mathml layout="container" data-formula="\[\int_D(∇⋅F)dV = \int_{∂D} F⋅ndS\]"></amp-mathml>
<div class="math-header">Definition of Christoffel Symbols</div>
<amp-mathml layout="container" data-formula="\[(∇_XY)^k = X^i(∇_iY)^k = X^i{\left({∂Y^k \over ∂x^i} + Γ_{im}^k Y^m\right)}\]"></amp-mathml>
<div class="math-header">Curl of a Vector Field</div>
<amp-mathml layout="container" data-formula="\[\overrightarrow{\nabla} × \overrightarrow{F} = \left(\frac{∂F_z}{∂y} − \frac{∂F_y}{∂z}\right)i + \left(\frac{∂F_x}{∂z} − \frac{∂F_z}{∂x}\right)j + \left(\frac{∂F_y}{∂x} − \frac{∂F_x}{∂y}\right)k\]"></amp-mathml>
<div class="math-header">Standard Deviation</div>
<amp-mathml layout="container" data-formula="\[σ = \sqrt{\frac{1}{N}\sum_{i=1}^N(x_i−μ)^2}\]"></amp-mathml>
<div class="math-header">Stephen Hawking's Entropy of a Black Hole</div>
<amp-mathml layout="container" data-formula="\[S = {kc^3A \over 4ℏG}\]"></amp-mathml>
<a href="https://www.royalmint.com/our-coins/events/stephen-hawking/?utm_source=RakutenMarketing&amp;utm_medium=Affiliate&amp;utm_campaign=2116208:Skimlinks.com&amp;utm_content=10:1&amp;utm_term=UKNetwork&amp;ranMID=37343&amp;ranEAID=TnL5HPStwNw&amp;ranSiteID=TnL5HPStwNw-Yy.LKaTZ_LBg5IpsOf3N.Q" title="Stephen Hawking 50p">
<amp-img class="smallzoomimgno" alt="Stephen Hawking 50p" title="Stephen Hawking 50p" src="images/Hawking-50p.png" width="240px" height="237px" style="margin-bottom:20px;float:right"></amp-img></a>