數學公式前端 | Katex |
Latex
% \f is defined as f(#1) using the macro
\f{x} = \int_{-\infty}^\infty
\hat \f\xi\,e^{2 \pi i \xi x}
\,d\xi
Katex
- 用latex表達數學公式
- 資源server side rendering或generate HTML
- To generate HTML on the server or to generate an HTML string of the rendered math, you can use
katex.renderToString:
var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
throwOnError: false
});
// '<span class="katex">...</span>'
MathJax
- 可以用latex表達數學公式
- 使用custom JavaScript,實作AMP比較困難
- The AMP pages only allow third-party JavaScript but only in sandboxed iframes. By restricting them to iframes, they can’t block the execution of the main page. Even if they trigger multiple style re-calculations, their tiny iframes have very little DOM.
- MathJax Docs
- SO: AMP support for Latex Maths
- How can we implement MathJax in AMP website
- SO: How can we implement MathJax in AMP website
- Add support for MathML
MathML
- 無法用latex表達數學公式
- 列示XML的markup language,不適合人去直接讀寫
- Mathematical Markup Language
github: mathml.js
amp-mathml