# @daiji256/rehype-mathml 中文文档

规范地址：https://npmcn.com/package/%40daiji256/rehype-mathml/

版本：1\.3\.0
npm 元数据更新时间：2026-10-12T03:49:45.382Z
中文译文更新时间：2026-11-11T08:56:20.303Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40daiji256/rehype-mathml
原文对照：https://npmcn.com/package/%40daiji256/rehype-mathml/?lang=original
项目主页：https://github.com/Daiji256/rehype-mathml#readme
源码仓库：https://github.com/Daiji256/rehype-mathml

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：9.7 kB，5 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：6 个
- 首次发布：2024-11-15T06:44:26.443Z
- 最新版本发布：2026-10-12T03:49:45.033Z
- 近 30 天下载量：4259（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：9（近 12 个月 2 个）

## 中文简介

用 MathML 制作数学的复韵插件

## 安装

```sh
npm install @daiji256/rehype-mathml
```

也可以使用：`pnpm add @daiji256/rehype-mathml`、`yarn add @daiji256/rehype-mathml`、`bun add @daiji256/rehype-mathml`

## README

# @daiji256/rehype-mathml (英语)

[![npm version](https://img.shields.io/npm/v/@daiji256/rehype-mathml.svg)](https://www.npmjs.com/package/@daiji256/rehype-mathmle) [![npm downloads](https://img.shields.io/npm/dm/@daiji256/rehype-mathml.svg)](https://www.npmjs.com/package/@daiji256/rehype-mathml)

**[复韵](https://github.com/rehypejs/rehype)** 用 MathML 制作数学的插件 使用teml将 LaTeX 数学转换为 MathML . 使用原因 [齿轮](https://temml.org/) 是个轻量级的图书馆 广泛覆盖了LaTeX功能.

## 目录

-   [目录](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-contents)
-   [这是什么?](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-what-is-this)
-   [我什么时候用这个?](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-when-should-i-use-this)
-   [安装](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-install)
-   [使用](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-use)
-   [API 密码](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-api)
    -   [`unified().use(rehypeMathML[, options])`](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-unifieduserehypemathml-options)
    -   [`Options`](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-options)
-   [标记](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-markdown)
-   [HTML 语言](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-html)
-   [类型](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-types)
-   [许可证](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-license)

## 这是什么?

这个软件包是 [统一](https://github.com/unifiedjs/unified) (单位:千美元)[复韵](https://github.com/rehypejs/rehype)) 与 MathML 一起制作数学的插件 . 您可以在 HTML 元素中添加类, 在标记下使用有栅栏的代码, 或者合并 与 [`remark-math`](https://github.com/remarkjs/remark-math/tree/main/packages/remark-math) (单位:千美元) `$C$` 语法扩展.

## 我什么时候用这个?

这个项目很有用,因为它让数学在编译时间, 这意味着不需要客户端JavaScript或图像.

此插件是其他插件的 MathML 版本, 如 [`rehype-mathjax`](https://github.com/remarkjs/remark-math/tree/main/packages/rehype-mathjax) (与 MathJax 交接)和 [`rehype-katex`](https://github.com/remarkjs/remark-math/tree/main/packages/rehype-katex) (与KaTeX交锋. 有了MathML,HTML就变得更简单更轻. 此外,它还支持使用数学字体,例如: [点数](https://github.com/notofonts/math)。 。 。 .

## 安装

在Node.js(第16版+)中,安装为 [无](https://docs.npmjs.com/cli/install)数字 :

```sh
npm install @daiji256/rehype-mathml
```

为了确保每个浏览器中数学表达式的正确渲染,您需要添加 [`Temml.woff2` 财务报告和审定财务报表 `Temml-*.css`](https://github.com/ronkok/Temml/tree/main/dist)。 。 。 .

## 使用

说我们的文件 `input.html` 包含:

```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` 包含:

```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` 改为:

```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`](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-unifieduserehypemathml-options)。 。 。 .

### `unified().use(rehypeMathML[, options])`

带a的渲染元素 `language-math` (或 `math-display`, (中文(简体) ), `math-inline`(中文(简体) ) 分类 [数学ML](https://www.w3.org/Math/)。 。 。 .

### `Options`

配置( TypeScript 类型).

```ts
import type { Options as TemmlOptions } from 'temml';

type Options = Partial<TemmlOptions>;
```

见 [_选项_ 打开 `temml.org`](https://temml.org/docs/en/administration#options) 需要更多信息.

## 标记

此插件支持启用的语法扩展 [`remark-math`](https://github.com/remarkjs/remark-math/tree/main/packages/remark-math)。 。 。 . 它还支持通过使用栅栏代码生成的数学:

````markdown
```math
C_L
```
````

## HTML 语言

含有一个 `language-math`, (中文(简体) ), `math-inline`,或 `math-display` 类被改变. 元素被由temml所转化出的MathML所取代. 无论是a `math-display` 分类或使用 `<pre><code class="language-math">` 将 结果是“显示”数学:数学是自身线上的一个障碍.

## 类型

此软件包已全部输入 [类型脚本](https://www.typescriptlang.org/)。 。 。 . 它输出额外类型 [`Options`](https://npmcn.com/package/%40daiji256/rehype-mathml/#readme-options)。 。 。 .

## 许可证

[麻省理工学院](https://npmcn.com/package/%40daiji256/rehype-mathml/LICENSE) © [大吉256号](https://github.com/Daiji256)

## 常见问题

### @daiji256/rehype-mathml 是什么？

用 MathML 制作数学的复韵插件

### 如何安装 @daiji256/rehype-mathml？

在项目目录运行 npm install @daiji256/rehype-mathml，或使用 pnpm add / yarn add / bun add。

### @daiji256/rehype-mathml 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @daiji256/rehype-mathml 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @daiji256/rehype-mathml 可以商用吗？

@daiji256/rehype-mathml 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @daiji256/rehype-mathml 的下载量有多少？

根据 npm 官方下载统计，@daiji256/rehype-mathml 在 2026/10/11 – 2026/11/09 这 30 天内被下载 4,259 次，日均约 142 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @daiji256/rehype-mathml 还在维护吗？

最新版本 1\.3\.0 发布于 2026/10/12（30 天前）；至今共发布 9 个版本，其中过去 12 个月发布了 2 个；首次发布于 2024/11/15。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

