@daiji256/rehype-mathml (英语)
复韵 用 MathML 制作数学的插件 使用teml将 LaTeX 数学转换为 MathML . 使用原因 齿轮 是个轻量级的图书馆 广泛覆盖了LaTeX功能.
目录
这是什么?
这个软件包是 统一 (单位:千美元)复韵) 与 MathML 一起制作数学的插件 .
您可以在 HTML 元素中添加类, 在标记下使用有栅栏的代码, 或者合并
与 remark-math (单位:千美元) $C$ 语法扩展.
我什么时候用这个?
这个项目很有用,因为它让数学在编译时间, 这意味着不需要客户端JavaScript或图像.
此插件是其他插件的 MathML 版本, 如
rehype-mathjax (与 MathJax 交接)和
rehype-katex (与KaTeX交锋.
有了MathML,HTML就变得更简单更轻.
此外,它还支持使用数学字体,例如: 点数。 。 。 .
安装
在Node.js(第16版+)中,安装为 无数字 :
npm install @daiji256/rehype-mathml
为了确保每个浏览器中数学表达式的正确渲染,您需要添加 Temml.woff2 财务报告和审定财务报表 Temml-*.css。 。 。 .
使用
说我们的文件 input.html 包含:
<p>
Lift(<code class="language-math">L</code>) can be determined by Lift
Coefficient (<code class="language-math">C_L</code>) like the following
equation.
</p>
<pre><code class="language-math">
L = \frac{1}{2} \rho v^2 S C_L
</code></pre>
...和我们的模块 example.js 包含:
import { unified } from 'unified';
import rehypeParse from 'rehype-parse';
import rehypeStringify from 'rehype-stringify';
import rehypeMathML from '@daiji256/rehype-mathml';
import { read, write } from 'to-vfile';
const file = await unified()
.use(rehypeParse, { fragment: true })
.use(rehypeMathML)
.use(rehypeStringify)
.process(await read('input.html'));
file.basename = 'output.html';
await write(file);
...然后运行 node example.js 创建一个 output.html 改为:
<p>
Lift(<math><!--…--></math>) can be determined by Lift
Coefficient (<math><!--…--></math>) like the following
equation.
</p>
<math display="block" class="tml-display" style="display:block math;"><!--…--></math>
...打开 output.html 在浏览器中看到所渲染的数学.
API 密码
此套件不导出标识符 .
默认导出为 rehypeMathML。 。 。 .
unified().use(rehypeMathML[, options])
带a的渲染元素 language-math (或 math-display, (中文(简体) ), math-inline(中文(简体) )
分类 数学ML。 。 。 .
Options
配置( TypeScript 类型).
import type { Options as TemmlOptions } from 'temml';
type Options = Partial<TemmlOptions>;
见 选项 打开 temml.org 需要更多信息.
标记
此插件支持启用的语法扩展
remark-math。 。 。 .
它还支持通过使用栅栏代码生成的数学:
```math
C_L
```
HTML 语言
含有一个 language-math, (中文(简体) ), math-inline,或
math-display 类被改变.
元素被由temml所转化出的MathML所取代.
无论是a math-display 分类或使用 <pre><code class="language-math"> 将
结果是“显示”数学:数学是自身线上的一个障碍.
类型
此软件包已全部输入 类型脚本。 。 。 .
它输出额外类型 Options。 。 。 .