Typeset plain-text formulas in DOCX files as native Word equations — cross-platform, no Office required.
Project description
MathFmt
MathFmt turns plain-text formulas in Word documents into native Word OMML equations — stacked fractions, radicals, superscripts, subscripts, derivatives, and standard mathematical operators — suitable for textbooks, exams, and technical reports.
Status
Beta (v0.2.0). Cross-platform OMML, confidence scoring, and expanded formula support.
中文
MathFmt 将 DOCX 中的普通文本公式排版为 Word 原生 OMML 公式。
快速示例
| 输入(纯文本) | 输出(Word 原生公式) |
|---|---|
ds(t)/dt |
堆叠分式 d s(t) / d t |
s'(t) = -s''(t) |
导数分数形式 |
sqrt(x^2 + 1) |
根号 √(x²+1) |
x^3 + p1 |
上标 x³ + 下标 p₁ |
x != 0 |
x ≠ 0 |
sin(x) + cos(x) |
sin(x) + cos(x) |
lim(p->0) |
lim 带下置 p→0 |
a/(b+c) |
堆叠分式 |
e^(p1*t) |
e 的 p₁t 次幂 |
1(t) |
u(t)(单位阶跃) |
Delta + pi |
Δ + π |
x, y, z |
逗号分隔序列 |
兼容性
| Windows 10/11 | macOS | Linux | |
|---|---|---|---|
| Python 3.10–3.13 | ✔ | ✔ | ✔ |
| 公式扫描 | ✔ | ✔ | ✔ |
| OMML 公式输出(内置 Python 后端) | ✔ | ✔ | ✔ |
| OMML 公式输出(Office XSL 后端) | ✔ | ✔¹ | ✔¹ |
| Word 渲染 | ✔ | ✔² | — |
¹ 需手动指定 MML2OMML.XSL 路径(--xsl)。
² macOS 版 Microsoft Word。
命令
mathfmt scan input.docx --report candidates.json # 扫描公式候选
mathfmt apply input.docx --review candidates.json --output out.docx --report result.json # 审核后转换
mathfmt convert input.docx # 保守一键转换
mathfmt validate input.docx # 离线结构验证
mathfmt doctor # 环境诊断
版本路线
| 版本 | 内容 |
|---|---|
| 0.1.0 (2026-06-21) | 基础扫描、审核、转换;原生 Word 公式输出;Windows + Office |
| 0.2.0 (2026-Q3) | 跨平台内置 OMML;置信度评分;独立验证;积分/求和/矩阵/向量/分段 |
| 0.3.0 (2026-Q4) | 正式语法引擎;LaTeX 输入;性能优化 |
| 1.0.0 (2027) | 稳定 API;长期支持 |
更多文档
维护
单人维护(Leo),尽力响应。欢迎提交 Issue 和 PR。安全漏洞请参阅 SECURITY.md。
English
MathFmt converts plain-text formulas in DOCX files into native Word OMML equations.
Quick Examples
| Input (plain text in DOCX) | Output (native Word equation) |
|---|---|
ds(t)/dt |
Stacked fraction d s(t) / d t |
s'(t) = -s''(t) |
Leibniz fraction derivatives |
sqrt(x^2 + 1) |
Radical √(x²+1) |
x^3 + p1 |
Superscript x³ + subscript p₁ |
x != 0 |
x ≠ 0 |
sin(x) + cos(x) |
sin(x) + cos(x) |
lim(p->0) |
lim with under-script p→0 |
a/(b+c) |
Stacked fraction |
e^(p1*t) |
e raised to p₁t |
1(t) |
u(t) (unit step) |
Delta + pi |
Δ + π |
x, y, z |
Comma-separated sequence |
Compatibility
| Windows 10/11 | macOS | Linux | |
|---|---|---|---|
| Python 3.10–3.13 | ✔ | ✔ | ✔ |
| Formula scanning | ✔ | ✔ | ✔ |
| OMML output (built-in Python backend) | ✔ | ✔ | ✔ |
| OMML output (Office XSL backend) | ✔ | ✔¹ | ✔¹ |
| Word rendering | ✔ | ✔² | — |
¹ Manual --xsl path required for Office XSL backend.
² Microsoft Word for Mac.
Commands
mathfmt scan input.docx --report candidates.json # Scan formula candidates
mathfmt apply input.docx --review candidates.json --output out.docx --report result.json # Apply reviewed candidates
mathfmt convert input.docx # Conservative one-step conversion
mathfmt validate input.docx # Offline structure validation
mathfmt doctor # Environment check
Version Roadmap
| Version | Scope |
|---|---|
| 0.1.0 (2026-06-21) | Scan, review, convert; native Word OMML; Windows + Office |
| 0.2.0 (2026-Q3) | Cross-platform built-in OMML; confidence scoring; validate; integrals, sums, matrices |
| 0.3.0 (2026-Q4) | Formal grammar engine; LaTeX input; performance |
| 1.0.0 (2027) | Stable API; long-term support |
Further Reading
- Formula Syntax Reference — every preprocessing rule, the full grammar, MathML output mapping, and known limitations
- Workflow Guide — step-by-step install, review flow, troubleshooting, CI usage
Maintenance
Single-maintainer project (Leo), best-effort response. Issues and pull requests are welcome. See CONTRIBUTING.md, CODE_OF_CONDUCT.md, and SECURITY.md.
Contributing
Issues and pull requests are welcome.
License
MIT License. Copyright (c) 2026 Leo.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mathfmt-0.2.0.tar.gz.
File metadata
- Download URL: mathfmt-0.2.0.tar.gz
- Upload date:
- Size: 34.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c7e033c9622a1c9b9d9ec7e42a384ddd4d2864ea2fea6e9ee50c662bde5e890
|
|
| MD5 |
d585b79311b4063f39c806e871d01560
|
|
| BLAKE2b-256 |
16b6e832bc7428a87bed1a06198fd44b308b7b3a60158282b8c028668e31564e
|
Provenance
The following attestation bundles were made for mathfmt-0.2.0.tar.gz:
Publisher:
publish.yml on gml853503962-creator/mathfmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mathfmt-0.2.0.tar.gz -
Subject digest:
6c7e033c9622a1c9b9d9ec7e42a384ddd4d2864ea2fea6e9ee50c662bde5e890 - Sigstore transparency entry: 1895665388
- Sigstore integration time:
-
Permalink:
gml853503962-creator/mathfmt@e6587b0041ab728f175b972d5476021e6551d2ab -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/gml853503962-creator
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e6587b0041ab728f175b972d5476021e6551d2ab -
Trigger Event:
push
-
Statement type:
File details
Details for the file mathfmt-0.2.0-py3-none-any.whl.
File metadata
- Download URL: mathfmt-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa819f01b1a652ec1ac1763251d1ef8f952450b4470bde9866a44b0cbf08b4ae
|
|
| MD5 |
c588d5ecf1a10394b92d9987701652ee
|
|
| BLAKE2b-256 |
4b98735551ec9f86b24b9c84a1135af2a616edcc9a4e51168043450fa0449e33
|
Provenance
The following attestation bundles were made for mathfmt-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on gml853503962-creator/mathfmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mathfmt-0.2.0-py3-none-any.whl -
Subject digest:
fa819f01b1a652ec1ac1763251d1ef8f952450b4470bde9866a44b0cbf08b4ae - Sigstore transparency entry: 1895665646
- Sigstore integration time:
-
Permalink:
gml853503962-creator/mathfmt@e6587b0041ab728f175b972d5476021e6551d2ab -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/gml853503962-creator
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e6587b0041ab728f175b972d5476021e6551d2ab -
Trigger Event:
push
-
Statement type: