Google-amp-mathml

提供:Dev Guides
移動先:案内検索

Google AMP-Mathml

MathMLを使用して、数式を表示できます。 この章では、MathMLの使用方法と、いくつかの数式を使用して同じものを表示する方法の実例を見て​​みましょう。

MathMLを使用するには、次のjavascriptファイルを含める必要があります-

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

MathML AMPタグ

mathML ampタグには、次のような形式があります-

<amp-mathml layout = "container"
   data-formula = "\[x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\]">
</amp-mathml>
*data-formula* は、式が与えられる必須属性であることに注意してください。

例の助けを借りて、このタグをよりよく理解しましょう。

<!doctype html>
<html amp lang = "en">
   <head>
      <meta charset = "utf-8">
      <script async src = "https://cdn.ampproject.org/v0.js"></script>
      <title>Google AMP - MathML</title>
      <link rel = "canonical" href = " http://example.ampproject.org/article-metadatal">
      <meta name = "viewport" content = "width = device-width,minimum-scale = 1,initial-scale = 1">

      <style amp-boilerplate>
         body{
            -webkit-animation:
            -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:
            -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:
            -amp-start 8s steps(1,end) 0s 1 normal both;animation:
            -amp-start 8s steps(1,end) 0s 1 normal both
         }
         @-webkit-keyframes
         -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes
         -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes
         -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes
         -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes
         -amp-start{from{visibility:hidden}to{visibility:visible}}
      </style>
      <noscript>
         <style amp-boilerplate>
            body{
               -webkit-animation:none;
               -moz-animation:none;
               -ms-animation:none;
               animation:none
            }
         </style>
      </noscript>

      <script async custom-element = "amp-mathml"
         src = "https://cdn.ampproject.org/v0/amp-mathml-0.1.js">
      </script>
   </head>
   <body>
      <h1>Google AMP - MathML Example</h1>
      <amp-mathml layout = "container"
         data-formula = "\[x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\]">
      </amp-mathml>
   </body>
</html>

出力

Amp-mathmlタグを実行すると、以下に示すようにiframeで表示がレンダリングされます-

Mathmlの例

Mathmlの例