1 Star 0 Fork 1

微笑/clone.MathJax-demos-web

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mml-attribute.html 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
Davide P. Cervone 提交于 2020-02-07 09:17 . Make sure IE opens as IE11
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width">
<title>Add a data-mathml attribute to each math element</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script>
MathJax = {
startup: {
ready: function () {
//
// Do the usual startup ready actions (create document, input/output jax, etc).
//
MathJax.startup.defaultReady();
const toMML = MathJax.startup.toMML;
//
// Add a post-filter to the output jax to add the extra attributes
//
MathJax.startup.output.postFilters.add((args) => {
const math = args.math, node = args.data;
const original = (math.math ? math.math :
math.inputJax.processStrings ? '' : math.start.node.outerHTML);
node.setAttribute('data-original', original);
node.setAttribute('data-mathml', toMML(math.root).replace(/\n\s*/g, ''));
});
}
}
};
</script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
</head>
<body>
<p>
This math will have a <code>data-mathml</code> attribute containing
the MathML representation of the expression, and a
<code>data-original</code> attribute holding the original TeX format
of the expression. Inspect the document DOM to see these in place
(on the <code>mjx-container</code> element).
</p>
$$\sqrt{\frac{1+x}{1-x}}$$
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/z.smile/clone.MathJax-demos-web.git
git@gitee.com:z.smile/clone.MathJax-demos-web.git
z.smile
clone.MathJax-demos-web
clone.MathJax-demos-web
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385