academic-mathtype-engine 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- academic_mathtype_engine-1.0.0/CHANGELOG.md +26 -0
- academic_mathtype_engine-1.0.0/LICENSE +202 -0
- academic_mathtype_engine-1.0.0/LICENSE_STATUS.md +5 -0
- academic_mathtype_engine-1.0.0/MANIFEST.in +10 -0
- academic_mathtype_engine-1.0.0/PKG-INFO +86 -0
- academic_mathtype_engine-1.0.0/README.md +61 -0
- academic_mathtype_engine-1.0.0/README.zh-CN.md +61 -0
- academic_mathtype_engine-1.0.0/THIRD_PARTY_NOTICES.md +20 -0
- academic_mathtype_engine-1.0.0/pyproject.toml +35 -0
- academic_mathtype_engine-1.0.0/setup.cfg +4 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype/__init__.py +7 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype/__main__.py +4 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype/cli.py +80 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype/compound.py +208 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype/document.py +227 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype/formula.py +181 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype/native.py +236 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype/opc.py +205 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype/prefix.py +104 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype/records.py +157 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype_engine.egg-info/PKG-INFO +86 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype_engine.egg-info/SOURCES.txt +24 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype_engine.egg-info/dependency_links.txt +1 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype_engine.egg-info/entry_points.txt +2 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype_engine.egg-info/requires.txt +10 -0
- academic_mathtype_engine-1.0.0/src/academic_mathtype_engine.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
- Ship the independent generator with build, validate and doctor. Keep sample-derived settings outside the release.
|
|
6
|
+
- Bind the maintainer’s Windows Word report to the delivered document and compare all its OPC parts with the candidate output.
|
|
7
|
+
- Scope owner approval and package inspection to the exact distribution payload.
|
|
8
|
+
|
|
9
|
+
## 1.0.0.dev1 — independent writer research branch
|
|
10
|
+
|
|
11
|
+
- Generate the MTEF header, CFB storage and Word object markup from format fields. The installed package excludes the frozen engine, extracted templates and historical regression documents.
|
|
12
|
+
- Add explicit local profile import, validation, selection and reset. Preserve the four Python entry points and the build/validate CLI.
|
|
13
|
+
- Add independent CFB checks, an original 105-equation desktop packet and bounded validation of incoming DOCX files. Add separate package-content, source-rights and desktop release gates.
|
|
14
|
+
- Windows Word/MathType editing of newly generated objects and owner licensing approval remain pending.
|
|
15
|
+
|
|
16
|
+
## 1.0.0rc1 — maintenance and distribution tooling
|
|
17
|
+
|
|
18
|
+
- Preserve the original v1.0.0-rc1 tag and all eight frozen source/fixture files.
|
|
19
|
+
- Add an installable Python package, command line interface, portable DOCX smoke tests and bilingual documentation.
|
|
20
|
+
- Retain the 100-equation desktop-validation artifact and 29 reproducible golden LaTeX/MTEF pairs.
|
|
21
|
+
- Add agent workflow instructions; document dependency, source, asset and release constraints.
|
|
22
|
+
- Public registry release remains gated by the licensing/provenance audit.
|
|
23
|
+
|
|
24
|
+
## v1.0.0-rc1 — original frozen baseline
|
|
25
|
+
|
|
26
|
+
The V11 encoder was frozen after the maintainer reported 100/100 desktop checks passed. See VALIDATION.md.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Distribution license and scope
|
|
2
|
+
|
|
3
|
+
The Apache License, Version 2.0 in LICENSE applies to the project-authored source, packaging files and documentation identified in the approved 1.0.0 source inventory. THIRD_PARTY_NOTICES.md describes separately installed components and mapping references. Their respective terms continue to apply. The release grants no rights in vendor trademarks, software or fonts.
|
|
4
|
+
|
|
5
|
+
The historical root engine, extracted templates, historical benchmark and user data are outside the inventory and outside this license designation. The release ledger and source/asset review describe the exact scope. The owner authorized publication of version 1.0.0 on PyPI on 2026-12-02.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Start with an empty sdist inventory, including on a setuptools-scm checkout.
|
|
2
|
+
global-exclude *
|
|
3
|
+
include LICENSE
|
|
4
|
+
include README.md README.zh-CN.md LICENSE_STATUS.md THIRD_PARTY_NOTICES.md CHANGELOG.md
|
|
5
|
+
include pyproject.toml MANIFEST.in
|
|
6
|
+
include src/academic_mathtype/__init__.py src/academic_mathtype/__main__.py
|
|
7
|
+
include src/academic_mathtype/cli.py src/academic_mathtype/formula.py src/academic_mathtype/records.py
|
|
8
|
+
include src/academic_mathtype/compound.py src/academic_mathtype/native.py
|
|
9
|
+
include src/academic_mathtype/document.py src/academic_mathtype/opc.py src/academic_mathtype/prefix.py
|
|
10
|
+
recursive-include src/academic_mathtype_engine.egg-info *.txt PKG-INFO
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: academic-mathtype-engine
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Generate embedded MathType-compatible equation objects in Word documents from LaTeX
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Repository, https://github.com/waterboyNick/academic-mathtype-engine
|
|
7
|
+
Project-URL: Documentation, https://github.com/waterboyNick/academic-mathtype-engine#readme
|
|
8
|
+
Project-URL: Issues, https://github.com/waterboyNick/academic-mathtype-engine/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
License-File: LICENSE_STATUS.md
|
|
16
|
+
License-File: THIRD_PARTY_NOTICES.md
|
|
17
|
+
Requires-Dist: python-docx<2,>=1.2
|
|
18
|
+
Requires-Dist: lxml<7,>=6.1.1
|
|
19
|
+
Requires-Dist: Pillow<13,>=12.3
|
|
20
|
+
Requires-Dist: matplotlib<4,>=3.10.8
|
|
21
|
+
Provides-Extra: test
|
|
22
|
+
Requires-Dist: olefile<1,>=0.47; extra == "test"
|
|
23
|
+
Requires-Dist: tomli>=2; python_version < "3.11" and extra == "test"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# Academic MathType Engine
|
|
27
|
+
|
|
28
|
+
Generate a Word equation collection from LaTeX on Linux, macOS or Windows. Each equation has its own embedded `Equation.DSMT4` OLE object and associated PNG preview. The independent backend constructs both parts locally. Word and MathType are required on the editing workstation only.
|
|
29
|
+
|
|
30
|
+
**Version 1.0.0.** The maintainer checked the delivered 105-equation document in Windows Word and reported that it worked. For the same inputs, the release writer reproduces all 227 document parts byte for byte. The exact desktop builds and per-equation editing observations were not reported. [中文](README.zh-CN.md) · [Verification](VALIDATION_REPORT.md) · [Licensing](LICENSE_STATUS.md)
|
|
31
|
+
|
|
32
|
+
## Install and generate
|
|
33
|
+
|
|
34
|
+
Use Python 3.10 or newer. Install from PyPI in your virtual environment.
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
python -m pip install academic-mathtype-engine==1.0.0
|
|
38
|
+
academic-mathtype doctor
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For a CLI example, save this UTF-8 array as `input.json`.
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
[
|
|
45
|
+
{"id":"eq1","label":"Quadratic fraction","latex":"\\frac{x_i^2+1}{y_0}"},
|
|
46
|
+
{"id":"eq2","label":"Inline variable","latex":"x+1","inline":true}
|
|
47
|
+
]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
academic-mathtype build input.json demo.docx
|
|
52
|
+
academic-mathtype validate demo.docx --expected 2
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The equivalent Python program is self-contained.
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from academic_mathtype import build_docx, compile_latex, pack_ole, validate_docx
|
|
59
|
+
|
|
60
|
+
cases = [{"id": "q", "label": "Normalized response", "latex": r"\frac{x_i^2+1}{y_0}"},
|
|
61
|
+
{"id": "r", "label": "Inline residual", "latex": "r=x-y", "inline": True}]
|
|
62
|
+
build_docx(cases, "equations.docx")
|
|
63
|
+
validate_docx("equations.docx", len(cases))
|
|
64
|
+
ole_bytes = pack_ole(compile_latex(cases[0]["latex"]))
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The CLI accepts a UTF-8 JSON array with these same fields. Escape each LaTeX backslash as `\\` in JSON. IDs must be unique. Use `--title` and `--per-page` to lay out a collection. The CLI requires `--overwrite` to replace a file. The Python API validates the entire document before replacing the destination. Installed commands are also available through `python -m academic_mathtype`.
|
|
68
|
+
|
|
69
|
+
## Formula and preview support
|
|
70
|
+
|
|
71
|
+
The grammar covers Latin and selected Greek symbols, functions, scripts, fractions, square roots, accents, vector and font styles, fences, six matrix/cases environments, integrals, sums, products and lower limits. Use paired braces for compound operands, e.g. `\sum_{i=1}^{n}{a_i-b_i}`. Indexed roots, arbitrary macros and arbitrary TeX environments are outside this dialect. Limits include 700 tokens per expression, 12 × 12 per matrix and a bounded native body of 1 MiB.
|
|
72
|
+
|
|
73
|
+
Install TeX providing `latex`, `amsmath`, `amssymb` and `dvipng` for the full preview set. With these commands missing, Matplotlib mathtext can render simpler previews. An unavailable preview or unsupported expression aborts the build. Read the diagnostic for the equation ID. Run `doctor` to check the native round trip and whether the TeX commands are discoverable on PATH.
|
|
74
|
+
|
|
75
|
+
## Verification and contribution
|
|
76
|
+
|
|
77
|
+
The frozen tests verify eight files, 29 exact MTEF bodies and 100 historical OLE/native hashes. The independent corpus includes 105 accepted inputs and 10 rejection cases. The checklist can record separate editing observations for specific desktop builds. [Historical record](VALIDATION.md) · [Acceptance materials](validation/) · [Architecture](ARCHITECTURE.md)
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
python -m pip install ".[test]"
|
|
81
|
+
python -m unittest -v test_engine test_frozen test_document
|
|
82
|
+
python -m unittest discover -s tests -v
|
|
83
|
+
python -m unittest discover -s release -v
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Submit changes on a branch with a minimal LaTeX input, its expected mathematical structure and a regression check. Keep private manuscripts, local profiles and third-party template binaries off the repository. Preserve the frozen manifest and tag. The package declares dependency ranges in `pyproject.toml`; `requirements.txt` records the historical reproduction versions. [Agent workflows](docs/SKILLS.md) · [Source provenance](SOURCE_PROVENANCE.md) · [Third-party notices](THIRD_PARTY_NOTICES.md) · [Publication gates](PYPI_RELEASE_READINESS.md)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Academic MathType Engine
|
|
2
|
+
|
|
3
|
+
Generate a Word equation collection from LaTeX on Linux, macOS or Windows. Each equation has its own embedded `Equation.DSMT4` OLE object and associated PNG preview. The independent backend constructs both parts locally. Word and MathType are required on the editing workstation only.
|
|
4
|
+
|
|
5
|
+
**Version 1.0.0.** The maintainer checked the delivered 105-equation document in Windows Word and reported that it worked. For the same inputs, the release writer reproduces all 227 document parts byte for byte. The exact desktop builds and per-equation editing observations were not reported. [中文](README.zh-CN.md) · [Verification](VALIDATION_REPORT.md) · [Licensing](LICENSE_STATUS.md)
|
|
6
|
+
|
|
7
|
+
## Install and generate
|
|
8
|
+
|
|
9
|
+
Use Python 3.10 or newer. Install from PyPI in your virtual environment.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
python -m pip install academic-mathtype-engine==1.0.0
|
|
13
|
+
academic-mathtype doctor
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
For a CLI example, save this UTF-8 array as `input.json`.
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
[
|
|
20
|
+
{"id":"eq1","label":"Quadratic fraction","latex":"\\frac{x_i^2+1}{y_0}"},
|
|
21
|
+
{"id":"eq2","label":"Inline variable","latex":"x+1","inline":true}
|
|
22
|
+
]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
academic-mathtype build input.json demo.docx
|
|
27
|
+
academic-mathtype validate demo.docx --expected 2
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The equivalent Python program is self-contained.
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from academic_mathtype import build_docx, compile_latex, pack_ole, validate_docx
|
|
34
|
+
|
|
35
|
+
cases = [{"id": "q", "label": "Normalized response", "latex": r"\frac{x_i^2+1}{y_0}"},
|
|
36
|
+
{"id": "r", "label": "Inline residual", "latex": "r=x-y", "inline": True}]
|
|
37
|
+
build_docx(cases, "equations.docx")
|
|
38
|
+
validate_docx("equations.docx", len(cases))
|
|
39
|
+
ole_bytes = pack_ole(compile_latex(cases[0]["latex"]))
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The CLI accepts a UTF-8 JSON array with these same fields. Escape each LaTeX backslash as `\\` in JSON. IDs must be unique. Use `--title` and `--per-page` to lay out a collection. The CLI requires `--overwrite` to replace a file. The Python API validates the entire document before replacing the destination. Installed commands are also available through `python -m academic_mathtype`.
|
|
43
|
+
|
|
44
|
+
## Formula and preview support
|
|
45
|
+
|
|
46
|
+
The grammar covers Latin and selected Greek symbols, functions, scripts, fractions, square roots, accents, vector and font styles, fences, six matrix/cases environments, integrals, sums, products and lower limits. Use paired braces for compound operands, e.g. `\sum_{i=1}^{n}{a_i-b_i}`. Indexed roots, arbitrary macros and arbitrary TeX environments are outside this dialect. Limits include 700 tokens per expression, 12 × 12 per matrix and a bounded native body of 1 MiB.
|
|
47
|
+
|
|
48
|
+
Install TeX providing `latex`, `amsmath`, `amssymb` and `dvipng` for the full preview set. With these commands missing, Matplotlib mathtext can render simpler previews. An unavailable preview or unsupported expression aborts the build. Read the diagnostic for the equation ID. Run `doctor` to check the native round trip and whether the TeX commands are discoverable on PATH.
|
|
49
|
+
|
|
50
|
+
## Verification and contribution
|
|
51
|
+
|
|
52
|
+
The frozen tests verify eight files, 29 exact MTEF bodies and 100 historical OLE/native hashes. The independent corpus includes 105 accepted inputs and 10 rejection cases. The checklist can record separate editing observations for specific desktop builds. [Historical record](VALIDATION.md) · [Acceptance materials](validation/) · [Architecture](ARCHITECTURE.md)
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
python -m pip install ".[test]"
|
|
56
|
+
python -m unittest -v test_engine test_frozen test_document
|
|
57
|
+
python -m unittest discover -s tests -v
|
|
58
|
+
python -m unittest discover -s release -v
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Submit changes on a branch with a minimal LaTeX input, its expected mathematical structure and a regression check. Keep private manuscripts, local profiles and third-party template binaries off the repository. Preserve the frozen manifest and tag. The package declares dependency ranges in `pyproject.toml`; `requirements.txt` records the historical reproduction versions. [Agent workflows](docs/SKILLS.md) · [Source provenance](SOURCE_PROVENANCE.md) · [Third-party notices](THIRD_PARTY_NOTICES.md) · [Publication gates](PYPI_RELEASE_READINESS.md)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Academic MathType Engine
|
|
2
|
+
|
|
3
|
+
在 Linux、macOS 或 Windows 上将 LaTeX 公式集合写入 Word。每条公式都含有一个 `Equation.DSMT4` 嵌入对象和与之关联的 PNG 预览。生成端使用 Python,编辑端需要兼容并已激活的桌面版 Word 和 MathType。
|
|
4
|
+
|
|
5
|
+
**版本 1.0.0。** 作者已在 Windows Word 检查上轮交付的 105 式文档,反馈“我已经完成检查了,Word 没问题。”相同输入下,本版生成的 227 个文档部件与该文件逐字节一致。具体桌面版本及逐式编辑结果未单独报告。[English](README.md) · [验证报告](VALIDATION_REPORT.md) · [授权状态](LICENSE_STATUS.md)
|
|
6
|
+
|
|
7
|
+
## 安装与使用
|
|
8
|
+
|
|
9
|
+
使用 Python 3.10 或更高版本,在虚拟环境中从 PyPI 安装。
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
python -m pip install academic-mathtype-engine==1.0.0
|
|
13
|
+
academic-mathtype doctor
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
使用 CLI 时,可将下面的 UTF-8 数组保存为 `input.json`。
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
[
|
|
20
|
+
{"id":"eq1","label":"Quadratic fraction","latex":"\\frac{x_i^2+1}{y_0}"},
|
|
21
|
+
{"id":"eq2","label":"Inline variable","latex":"x+1","inline":true}
|
|
22
|
+
]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
academic-mathtype build input.json demo.docx
|
|
27
|
+
academic-mathtype validate demo.docx --expected 2
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
也可以直接运行以下 Python 示例。
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from academic_mathtype import build_docx, compile_latex, pack_ole, validate_docx
|
|
34
|
+
|
|
35
|
+
cases = [{"id": "q", "label": "归一化响应", "latex": r"\frac{x_i^2+1}{y_0}"},
|
|
36
|
+
{"id": "r", "label": "行内残差", "latex": "r=x-y", "inline": True}]
|
|
37
|
+
build_docx(cases, "equations.docx")
|
|
38
|
+
validate_docx("equations.docx", len(cases))
|
|
39
|
+
ole_bytes = pack_ole(compile_latex(cases[0]["latex"]))
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
CLI 输入为 UTF-8 JSON 数组,字段见示例。JSON 字符串中的 LaTeX 反斜杠写成 `\\`。每条公式须有唯一 ID。`--title` 设置标题,`--per-page` 设置每组公式数量;CLI 覆盖已有文件需显式传入 `--overwrite`。Python API 在临时文件通过验证后替换目标。也可用 `python -m academic_mathtype` 调用同一入口。
|
|
43
|
+
|
|
44
|
+
## 公式与预览
|
|
45
|
+
|
|
46
|
+
支持部分希腊字母与数学符号、函数、上下标、分式、平方根、重音、向量、字体、围栏、矩阵、分段函数、积分、求和、连乘和下极限。大型算子的复合操作数请加花括号,例如 `\sum_{i=1}^{n}{a_i-b_i}`。当前边界包括单式 700 个词法单元、矩阵 12 × 12、原生表达式数据 1 MiB。任意宏、指定次数的根式及未列出的环境会触发错误。
|
|
47
|
+
|
|
48
|
+
完整预览需要 TeX 环境提供 `latex`、`amsmath`、`amssymb` 和 `dvipng`。缺少命令时使用 Matplotlib mathtext,适用于较简单的公式。生成失败时查看错误中的公式 ID。使用 `doctor` 检查原生数据往返和 TeX 命令路径。未支持语法或预览失败会终止生成。
|
|
49
|
+
|
|
50
|
+
## 验证与贡献
|
|
51
|
+
|
|
52
|
+
历史回归覆盖八个冻结文件、29 组精确编码、100 个历史对象及其原生流哈希。新测试集含 105 个有效输入和 10 个应拒输入,另附逐式编辑记录表。新后端的 Word、MathType 版本范围以实际验收记录为准。[历史记录](VALIDATION.md) · [新验收材料](validation/) · [架构说明](ARCHITECTURE.md)
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
python -m pip install ".[test]"
|
|
56
|
+
python -m unittest -v test_engine test_frozen test_document
|
|
57
|
+
python -m unittest discover -s tests -v
|
|
58
|
+
python -m unittest discover -s release -v
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
贡献代码时请提供最小 LaTeX 输入、预期数学结构及回归验证。请保留冻结清单与标签,避免提交私有稿件、用户配置和第三方模板。当前依赖范围见 `pyproject.toml`,历史复现版本见 `requirements.txt`。[Agent 使用说明](docs/SKILLS.md) · [源码审计](SOURCE_PROVENANCE.md) · [第三方声明](THIRD_PARTY_NOTICES.md) · [发行门禁](PYPI_RELEASE_READINESS.md)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Third-party components and historical references
|
|
2
|
+
|
|
3
|
+
This inventory distinguishes install-time components from repositories consulted during historical development. Exact copyright notices and license texts for material approved for distribution must accompany that distribution as required. [Rights status](LICENSE_STATUS.md) · [Function-level provenance](SOURCE_PROVENANCE.md)
|
|
4
|
+
|
|
5
|
+
| Component | Use and observed terms |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| npofsi/docx-equation | Historical MTEF/OLE investigation. Copyright © 2026 npofsi in the MIT v0.3.0 archives. Later source metadata declares AGPL-3.0-only. The final payload review identified no incorporated upstream implementation. [Version evidence](SOURCE_PROVENANCE.md) |
|
|
8
|
+
| loveTimish/latextomathtype | Historical record conventions and diagnostics. No project-wide license file found in inspected reachable history. An earlier README designation was removed. [History and attribution](SOURCE_PROVENANCE.md) |
|
|
9
|
+
| MathType / WIRIS and Microsoft Word | Product and format identifiers describe interoperability. Historical shell, XML and benchmark contain material extracted from or generated with proprietary tools. The project is independent of the vendors. [Asset inventory](ASSET_PROVENANCE.md) |
|
|
10
|
+
| python-docx 1.2.0 | MIT. The installed dependency supplies the blank DOCX container, including its default document parts. [License](https://github.com/python-openxml/python-docx/blob/v1.2.0/LICENSE) |
|
|
11
|
+
| lxml 6.1.1 | BSD-3-Clause according to package metadata. Distributed lxml wheels can carry libxml2, libxslt and additional notices. [Project licensing](https://lxml.de/copyright.html) |
|
|
12
|
+
| Pillow 12.3.0 | MIT-CMU metadata. See individual binary distributions for their bundled library notices. [Pillow license](https://pillow.readthedocs.io/en/stable/about.html#license) |
|
|
13
|
+
| Matplotlib 3.10.8 | Matplotlib's PSF-style license, with separate notices for bundled software and fonts, including assets usable by the preview renderer. [License and dependencies](https://matplotlib.org/stable/project/license.html) |
|
|
14
|
+
| olefile 0.47 | BSD license for independent compound-file inspection. [Project licensing](https://www.decalage.info/olefile) |
|
|
15
|
+
| tomli | Conditional test/release tooling for Python versions lacking tomllib. MIT. [License](https://github.com/hukkin/tomli/blob/master/LICENSE) |
|
|
16
|
+
| TeX distribution, LaTeX, dvipng and fonts | Optional, installed by the user or test environment. Individual packages and fonts have their own terms. A binary, font program or complete TeX distribution would require a separate redistribution review. [TeX Live licensing](https://tug.org/texlive/copying.html) |
|
|
17
|
+
|
|
18
|
+
The listed versions identify reviewed installations. Actual dependency versions and bundled native libraries depend on platform and resolver. The wheel and sdist inventory should be checked separately for each approved package release. No upstream implementation archive, WIRIS SDK or proprietary font is authorized by this inventory.
|
|
19
|
+
|
|
20
|
+
The selected mathematical glyph positions were checked against the Adobe Symbol Encoding to Unicode mapping, copyright © 1991–2011 Unicode, Inc. The table permits use of its information in products supporting Unicode. Neither the mapping file nor the font is bundled. Python’s HTML entity mapping is accessed through the installed standard library. [Unicode mapping and notice](https://www.unicode.org/Public/MAPPINGS/VENDORS/ADOBE/symbol.txt)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0.3"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "academic-mathtype-engine"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Generate embedded MathType-compatible equation objects in Word documents from LaTeX"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"python-docx>=1.2,<2",
|
|
13
|
+
"lxml>=6.1.1,<7",
|
|
14
|
+
"Pillow>=12.3,<13",
|
|
15
|
+
"matplotlib>=3.10.8,<4",
|
|
16
|
+
]
|
|
17
|
+
license = "Apache-2.0"
|
|
18
|
+
license-files = ["LICENSE", "LICENSE_STATUS.md", "THIRD_PARTY_NOTICES.md"]
|
|
19
|
+
classifiers = ["Programming Language :: Python :: 3", "Topic :: Scientific/Engineering", "Operating System :: OS Independent"]
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
test = ["olefile>=0.47,<1", "tomli>=2; python_version < '3.11'"]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Repository = "https://github.com/waterboyNick/academic-mathtype-engine"
|
|
26
|
+
Documentation = "https://github.com/waterboyNick/academic-mathtype-engine#readme"
|
|
27
|
+
Issues = "https://github.com/waterboyNick/academic-mathtype-engine/issues"
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
academic-mathtype = "academic_mathtype.cli:main"
|
|
31
|
+
|
|
32
|
+
[tool.setuptools]
|
|
33
|
+
packages = ["academic_mathtype"]
|
|
34
|
+
package-dir = {"" = "src"}
|
|
35
|
+
include-package-data = false
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""Generate and structurally validate native equation objects in Word documents."""
|
|
2
|
+
from .document import build_docx, validate_docx
|
|
3
|
+
from .formula import UnsupportedFormula, compile_latex
|
|
4
|
+
from .native import pack_ole
|
|
5
|
+
|
|
6
|
+
__version__ = "1.0.0"
|
|
7
|
+
__all__ = ["UnsupportedFormula", "build_docx", "compile_latex", "pack_ole", "validate_docx"]
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""Command-line interface for independent equation generation."""
|
|
2
|
+
import argparse
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import shutil
|
|
7
|
+
import sys
|
|
8
|
+
import tempfile
|
|
9
|
+
|
|
10
|
+
from . import __version__
|
|
11
|
+
from .document import build_docx, validate_docx
|
|
12
|
+
from .formula import compile_latex
|
|
13
|
+
from .native import pack_ole, read_body
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _commands():
|
|
17
|
+
parser = argparse.ArgumentParser(prog="academic-mathtype")
|
|
18
|
+
parser.add_argument("--version", action="version", version=__version__)
|
|
19
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
20
|
+
|
|
21
|
+
build = sub.add_parser("build", help="Generate an equation collection")
|
|
22
|
+
build.add_argument("input", type=Path)
|
|
23
|
+
build.add_argument("output", type=Path)
|
|
24
|
+
build.add_argument("--title", default="MathType equation collection")
|
|
25
|
+
build.add_argument("--per-page", type=int, default=5)
|
|
26
|
+
build.add_argument("--overwrite", action="store_true")
|
|
27
|
+
|
|
28
|
+
check = sub.add_parser("validate", help="Validate embedded equation objects and previews")
|
|
29
|
+
check.add_argument("document", type=Path)
|
|
30
|
+
check.add_argument("--expected", type=int, required=True)
|
|
31
|
+
|
|
32
|
+
sub.add_parser("doctor", help="Check native records and preview tools")
|
|
33
|
+
return parser
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _build(args):
|
|
37
|
+
if args.output.suffix.lower() != ".docx" or args.per_page < 1:
|
|
38
|
+
raise ValueError("Use a .docx output and a positive --per-page")
|
|
39
|
+
if not args.overwrite and args.output.exists():
|
|
40
|
+
raise FileExistsError(f"Output already exists: {args.output}")
|
|
41
|
+
with args.input.open("rb") as stream:
|
|
42
|
+
data = stream.read(2 * 1024 * 1024 + 1)
|
|
43
|
+
if len(data) > 2 * 1024 * 1024:
|
|
44
|
+
raise ValueError("Equation collection JSON exceeds 2 MiB")
|
|
45
|
+
cases = json.loads(data.decode("utf-8-sig"))
|
|
46
|
+
options = dict(title=args.title, per_page=args.per_page)
|
|
47
|
+
if args.overwrite:
|
|
48
|
+
build_docx(cases, args.output, **options)
|
|
49
|
+
else:
|
|
50
|
+
# Link a complete file into place. An intervening concurrent creator wins.
|
|
51
|
+
with tempfile.TemporaryDirectory(dir=args.output.resolve().parent) as directory:
|
|
52
|
+
staged = Path(directory) / "equations.docx"
|
|
53
|
+
build_docx(cases, staged, **options)
|
|
54
|
+
os.link(staged, args.output)
|
|
55
|
+
print(f"Built and structurally validated {len(cases)} objects: {args.output}")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def main(argv=None):
|
|
59
|
+
args = _commands().parse_args(argv)
|
|
60
|
+
try:
|
|
61
|
+
if args.command == "build":
|
|
62
|
+
_build(args)
|
|
63
|
+
elif args.command == "validate":
|
|
64
|
+
if args.expected < 1:
|
|
65
|
+
raise ValueError("--expected must be positive")
|
|
66
|
+
validate_docx(args.document, args.expected)
|
|
67
|
+
print(f"Structural validation passed: {args.document}")
|
|
68
|
+
elif args.command == "doctor":
|
|
69
|
+
body = compile_latex(r"\frac{x_i}{2}")
|
|
70
|
+
if read_body(pack_ole(body)) != body:
|
|
71
|
+
raise ValueError("Native equation self-test failed")
|
|
72
|
+
print(json.dumps({
|
|
73
|
+
"version": __version__, "backend": "independent",
|
|
74
|
+
"native_round_trip": "passed", "latex": shutil.which("latex"),
|
|
75
|
+
"dvipng": shutil.which("dvipng"),
|
|
76
|
+
}, ensure_ascii=False, indent=2))
|
|
77
|
+
return 0
|
|
78
|
+
except Exception as exc:
|
|
79
|
+
print(f"Error: {type(exc).__name__}: {exc}", file=sys.stderr)
|
|
80
|
+
return 1
|