구글 AMP – MathML

1 min read

MathML을 사용하여 수학 공식을 표시할 수 있습니다. 이 글에서는 MathML을 사용하는 방법과 몇 가지 수학 공식을 사용하여 동일한 결과를 표시하는 방법에 대한 실제 예제를 살펴보겠습니다.

MathML을 사용하려면 다음 자바스크립트 파일을 포함해야 합니다.

<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 ⚡ lang="ko">
<head>
  <meta charset="utf-8">
  <script async src="https://cdn.ampproject.org/v0.js"></script>
  <title>Google AMP - MathML</title>
  <link rel="canonical" href="https://googleblogamp.blogspot.com/2021/01/google-amp-mathml.html">
  <meta name="viewport" content="width=device-width,minimum-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에서 디스플레이를 렌더링합니다.

구글 AMP – MathML
방문해주셔서 감사합니다. 즐거운 하루 되세요!

관심 있을 만한 글

  • Google Accelerated Mobile Pages (Google AMP)는 amp-html을 사용하여 웹 페이지를 경량화하여 구현할 수 있도록 특별히 만들어진 Google의 새로운 오픈 소스 프로젝트입니다. 이 프로젝트의 주요 목표는 AMP 코드를 잘 적용하여 스마트폰, 태블릿 등과 같은 가능한 모…
  • 유효성 검사는 AMP 페이지에 문제가 있을 때 알려주며, 페이지의 어느 부분에서 문제가 발생했는지 알 수 있기 때문에 매우 유용합니다. AMP 페이지의 유효성을 검사하지 않으면 AMP 캐시에 포함되지 않습니다. 즉, 클릭함과 동시에 즉시 로드되는 페이지를 만들지 못합니다…
  • 구글 가속 모바일 페이지(Google Accelerated Mobile Pages, Google AMP)는 구글의 오픈 소스 프로젝트로 amp-html을 사용하여 가벼운 웹 페이지를 빌드합니다. 구글의 새로운 오픈 메인 프로그램인 AMP는 스마트폰과 태블릿같은 가능한 모든 …
  • HTML에 대한 기본적인 지식이 있다고 가정하고 간단한 HTML5 페이지를 AMP-HTML로 변환해보겠습니다. 표준 AMP 페이지, 즉 데스크톱 페이지가 없는 독립형 AMP 페이지를 구축하지 않는 한, 일반적으로 전체 HTML 페이지를 AMP-HTML로 변환합니다. …
  • AMP 맞춤 자바스크립트 오류는 AMP 오류 중 가장 흔한 오류입니다. 맞춤 자바스크립트 오류 발생 원인과 "맞춤 자바스크립트는 허용되지 않습니다." 문제를 해결하는 방법에 대해 알아봅니다. 맞춤 자바스크립트란? AMP 페이지 내에서 허용되지 않는 모든 자바…
  • 구글 검색 결과에서 이 번개 표시는 무엇일까요? 이 번개 표시는 Google의 AMP 프로젝트 로고로, 빠른 모바일 웹 페이지라는 Google 인증 배지 입니다. AMP 프로젝트 로고가 번개 모양인 이유가 있습니다. 실제로 AMP 페이지는 번개처럼 빠르기 때문입니다. …

댓글 쓰기