rapier-math 1.1.1 → 2.1.0
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.
- package/README.md +15 -5
- package/dist/accessible.css +6 -0
- package/dist/accessible.d.ts +10 -0
- package/dist/accessible.mjs +18 -0
- package/dist/classic.d.ts +8 -2
- package/dist/combined.d.ts +4 -0
- package/dist/combined.mjs +2 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.mjs +6 -2980
- package/dist/integration.d.ts +11 -2
- package/dist/integration.mjs +96 -13
- package/dist/markdown-it.d.ts +7 -0
- package/dist/markdown-it.mjs +33 -19
- package/dist/mathml.d.ts +5 -0
- package/dist/mathml.mjs +3 -0
- package/dist/rapier-math.js +595 -143
- package/dist/rehype.d.ts +7 -0
- package/dist/rehype.mjs +28 -7
- package/dist/reuse.mjs +110 -0
- package/dist/stream.d.ts +36 -3
- package/dist/stream.mjs +63 -38
- package/docs/api.md +155 -26
- package/docs/math-components.json +6 -5
- package/docs/math-resources.json +170 -68
- package/docs/semantics.md +228 -0
- package/examples/README.md +15 -2
- package/examples/accessible.html +27 -0
- package/examples/accessible.mjs +42 -0
- package/examples/markdown.mjs +21 -4
- package/examples/semantic.mjs +11 -0
- package/examples/stream.mjs +31 -11
- package/examples/unified.mjs +17 -3
- package/package.json +16 -2
- package/src/math/api.js +16 -55
- package/src/math/browser.js +4 -0
- package/src/math/classic.js +7 -0
- package/src/math/combined.js +13 -0
- package/src/math/fallbacks.js +5 -0
- package/src/math/font.js +3 -0
- package/src/math/layout.js +6 -37
- package/src/math/mathml.js +406 -0
- package/src/math/package-build.mjs +24 -11
- package/src/math/package-layout.mjs +3 -0
- package/src/math/package-readme.mjs +14 -4
- package/src/math/parser.js +14 -11
- package/src/math/responsive.js +4 -0
- package/src/math/semantic-api.js +12 -0
- package/src/math/source.js +67 -0
- package/src/math/symbols.js +3 -0
- package/src/math/variants.js +41 -0
- package/src/tools/build-math.mjs +20 -11
- package/tests/adoption.mjs +112 -9
- package/tests/check.mjs +20 -5
- package/tests/semantics.mjs +340 -0
- package/tests/verify.mjs +6 -3
package/docs/math-resources.json
CHANGED
|
@@ -1,60 +1,96 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundle": "rapier-math-
|
|
2
|
+
"bundle": "rapier-math-2.1.0.js",
|
|
3
3
|
"packageBundle": "dist/rapier-math.js",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"license": "MIT AND LicenseRef-GUST-Font-License",
|
|
6
|
-
"bytes":
|
|
7
|
-
"gzipBytes":
|
|
8
|
-
"sha256": "
|
|
9
|
-
"sha384": "
|
|
6
|
+
"bytes": 745053,
|
|
7
|
+
"gzipBytes": 451500,
|
|
8
|
+
"sha256": "e1667405881f03e4757563ad9ea34202ba6d3413944b5cc648dc4280b66d567a",
|
|
9
|
+
"sha384": "3+lJzhwiyTiz1ptqIPqrbS/tkfjIki9QnvSY4kyFBv7MCDiH5LmvNUk8CMlaPg9Z",
|
|
10
10
|
"sources": [
|
|
11
11
|
{
|
|
12
12
|
"file": "math/font.js",
|
|
13
13
|
"packageFile": "src/math/font.js",
|
|
14
|
-
"bytes":
|
|
15
|
-
"sha256": "
|
|
14
|
+
"bytes": 558741,
|
|
15
|
+
"sha256": "ca92701353de9b79527e133d1b44931dedf2a5e647561d4b80626d86f74e7e8b"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"file": "math/symbols.js",
|
|
19
19
|
"packageFile": "src/math/symbols.js",
|
|
20
|
-
"bytes":
|
|
21
|
-
"sha256": "
|
|
20
|
+
"bytes": 8484,
|
|
21
|
+
"sha256": "0f711ac551d950ba62acbc5cf84d1362276498fbb7809fad55c97d98be100a95"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"file": "math/parser.js",
|
|
25
25
|
"packageFile": "src/math/parser.js",
|
|
26
|
-
"bytes":
|
|
27
|
-
"sha256": "
|
|
26
|
+
"bytes": 69789,
|
|
27
|
+
"sha256": "50d740a6190d3ec3218fcf76a1cd7eb74ef18f638e265c5c591e5e943ea91549"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"file": "math/source.js",
|
|
31
|
+
"packageFile": "src/math/source.js",
|
|
32
|
+
"bytes": 3248,
|
|
33
|
+
"sha256": "e6e52a8377df06bbd30df1e6249e3e9eccdeabbf1c2b7482c17820a9a2a1d313"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"file": "math/variants.js",
|
|
37
|
+
"packageFile": "src/math/variants.js",
|
|
38
|
+
"bytes": 2093,
|
|
39
|
+
"sha256": "459311776b8c5734110dfd8eae2c8fdda3c6e8783d43822055ee8c61e520cea6"
|
|
28
40
|
},
|
|
29
41
|
{
|
|
30
42
|
"file": "math/layout.js",
|
|
31
43
|
"packageFile": "src/math/layout.js",
|
|
32
|
-
"bytes":
|
|
33
|
-
"sha256": "
|
|
44
|
+
"bytes": 36115,
|
|
45
|
+
"sha256": "5662f8fd6dd15e496b755d44fc6c0f81589d1eafd49176522e7b7da887c049c9"
|
|
34
46
|
},
|
|
35
47
|
{
|
|
36
48
|
"file": "math/fallbacks.js",
|
|
37
49
|
"packageFile": "src/math/fallbacks.js",
|
|
38
|
-
"bytes":
|
|
39
|
-
"sha256": "
|
|
50
|
+
"bytes": 8214,
|
|
51
|
+
"sha256": "ff572ad147f348508ee966de9936efb996283b7978bee909bf9a208bcd46456c"
|
|
40
52
|
},
|
|
41
53
|
{
|
|
42
54
|
"file": "math/responsive.js",
|
|
43
55
|
"packageFile": "src/math/responsive.js",
|
|
44
|
-
"bytes":
|
|
45
|
-
"sha256": "
|
|
56
|
+
"bytes": 13839,
|
|
57
|
+
"sha256": "d0cff2fd9a520d30b75b1d49074d93d2500c5f32ca6aaa30239498fe6d860e07"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"file": "math/api.js",
|
|
61
|
+
"packageFile": "src/math/api.js",
|
|
62
|
+
"bytes": 5109,
|
|
63
|
+
"sha256": "2611332afa0065df89c83339fd1a2b1d08d8e0bae447aed8bead1187bac96c1b"
|
|
46
64
|
},
|
|
47
65
|
{
|
|
48
66
|
"file": "math/browser.js",
|
|
49
67
|
"packageFile": "src/math/browser.js",
|
|
50
|
-
"bytes":
|
|
51
|
-
"sha256": "
|
|
68
|
+
"bytes": 10172,
|
|
69
|
+
"sha256": "c56a36031169a40bbcbaa6be2b197945b5819ca0446392ae2142255ad2a5baa6"
|
|
52
70
|
},
|
|
53
71
|
{
|
|
54
|
-
"file": "math/
|
|
55
|
-
"packageFile": "src/math/
|
|
56
|
-
"bytes":
|
|
57
|
-
"sha256": "
|
|
72
|
+
"file": "math/mathml.js",
|
|
73
|
+
"packageFile": "src/math/mathml.js",
|
|
74
|
+
"bytes": 28871,
|
|
75
|
+
"sha256": "b337126ecbcfa078e0bd29ef5e33bce0f2b5f792e02935d29beb50ecdc7bbbeb"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"file": "math/semantic-api.js",
|
|
79
|
+
"packageFile": "src/math/semantic-api.js",
|
|
80
|
+
"bytes": 449,
|
|
81
|
+
"sha256": "973773cfc5f1066215c9ae4598515e6744dc74789ee5d9d5c1c6fec5058c6c2c"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"file": "math/combined.js",
|
|
85
|
+
"packageFile": "src/math/combined.js",
|
|
86
|
+
"bytes": 649,
|
|
87
|
+
"sha256": "1291d53911fc91c7f544862bc41b1a23909748208d781e79d93fa35ff8618a22"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"file": "math/classic.js",
|
|
91
|
+
"packageFile": "src/math/classic.js",
|
|
92
|
+
"bytes": 269,
|
|
93
|
+
"sha256": "74b3c1332e179113286465e082d44515876fa784ec1d76142e6660f367a7604b"
|
|
58
94
|
}
|
|
59
95
|
],
|
|
60
96
|
"recipe": [
|
|
@@ -79,14 +115,14 @@
|
|
|
79
115
|
{
|
|
80
116
|
"file": "math/package-verify.mjs",
|
|
81
117
|
"packageFile": "tests/verify.mjs",
|
|
82
|
-
"bytes":
|
|
83
|
-
"sha256": "
|
|
118
|
+
"bytes": 3179,
|
|
119
|
+
"sha256": "5702cb77eb562b0230b145c09b8888b2b20bcf8dac92de19615aac99a0f09a47"
|
|
84
120
|
},
|
|
85
121
|
{
|
|
86
122
|
"file": "tools/build-math.mjs",
|
|
87
123
|
"packageFile": "src/tools/build-math.mjs",
|
|
88
|
-
"bytes":
|
|
89
|
-
"sha256": "
|
|
124
|
+
"bytes": 9573,
|
|
125
|
+
"sha256": "ef053202ffc95e9ae801be789356775381d18c9ab1ac16aa28ee941294bb328e"
|
|
90
126
|
},
|
|
91
127
|
{
|
|
92
128
|
"file": "math/LICENSE-MIT",
|
|
@@ -97,38 +133,50 @@
|
|
|
97
133
|
{
|
|
98
134
|
"file": "math/adoption-verify.mjs",
|
|
99
135
|
"packageFile": "tests/adoption.mjs",
|
|
100
|
-
"bytes":
|
|
101
|
-
"sha256": "
|
|
136
|
+
"bytes": 15517,
|
|
137
|
+
"sha256": "02e22c51e0c71de1fe992b3fddde04e2e2cfc482d1c05aa1467a1c97c7d63b58"
|
|
102
138
|
},
|
|
103
139
|
{
|
|
104
140
|
"file": "math/package-build.mjs",
|
|
105
141
|
"packageFile": "src/math/package-build.mjs",
|
|
106
|
-
"bytes":
|
|
107
|
-
"sha256": "
|
|
142
|
+
"bytes": 1252,
|
|
143
|
+
"sha256": "d5a3562438e4e5f92796186b53d29afe71cd8f2266b65ef77b6e44e459598e79"
|
|
108
144
|
},
|
|
109
145
|
{
|
|
110
146
|
"file": "math/package-layout.mjs",
|
|
111
147
|
"packageFile": "src/math/package-layout.mjs",
|
|
112
|
-
"bytes":
|
|
113
|
-
"sha256": "
|
|
148
|
+
"bytes": 832,
|
|
149
|
+
"sha256": "6c693d84a10a21cc306afcefcb188279a2c5ca5cfdf6b4d808f933a8ea12d74a"
|
|
114
150
|
},
|
|
115
151
|
{
|
|
116
152
|
"file": "math/package-check.mjs",
|
|
117
153
|
"packageFile": "tests/check.mjs",
|
|
118
|
-
"bytes":
|
|
119
|
-
"sha256": "
|
|
154
|
+
"bytes": 8662,
|
|
155
|
+
"sha256": "b9bb518590aa85a3e3e6f14bbc149b112ec73ca05259234358a8460a2ada28f3"
|
|
120
156
|
},
|
|
121
157
|
{
|
|
122
158
|
"file": "math/package-readme.mjs",
|
|
123
159
|
"packageFile": "src/math/package-readme.mjs",
|
|
124
|
-
"bytes":
|
|
125
|
-
"sha256": "
|
|
160
|
+
"bytes": 2682,
|
|
161
|
+
"sha256": "8cb6381d64e39150249e8e38fe6b51d2e0de1f800421cb35f6ed1a005d40a1be"
|
|
126
162
|
},
|
|
127
163
|
{
|
|
128
164
|
"file": "math/README.md",
|
|
129
165
|
"packageFile": "docs/api.md",
|
|
130
|
-
"bytes":
|
|
131
|
-
"sha256": "
|
|
166
|
+
"bytes": 23108,
|
|
167
|
+
"sha256": "2b79d323c03ba11e6c051d07f4cd688ec9b1f68479c831f426ec276c36ed7b2c"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"file": "math/SEMANTICS.md",
|
|
171
|
+
"packageFile": "docs/semantics.md",
|
|
172
|
+
"bytes": 18096,
|
|
173
|
+
"sha256": "c1b63412b38fc96f3b96161584f01ea0eddd194a98d27cd535a5007ba3936847"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"file": "math/semantic-verify.mjs",
|
|
177
|
+
"packageFile": "tests/semantics.mjs",
|
|
178
|
+
"bytes": 27391,
|
|
179
|
+
"sha256": "9fc8a03da77d3532a0aaa69e02d773aaa9e9aa5e3386b666acb27a4b0079ffdb"
|
|
132
180
|
}
|
|
133
181
|
],
|
|
134
182
|
"components": [
|
|
@@ -166,41 +214,77 @@
|
|
|
166
214
|
"bytes": 3255,
|
|
167
215
|
"sha256": "3c2c1660f669eac88fbee4259e83f9227ed651e2e4bb228a861c5a1d8518f6a7"
|
|
168
216
|
},
|
|
217
|
+
{
|
|
218
|
+
"file": "math/reuse.mjs",
|
|
219
|
+
"packageFile": "dist/reuse.mjs",
|
|
220
|
+
"bytes": 5590,
|
|
221
|
+
"sha256": "fe3f9d669429cf7635d4c11fbd7f74b955d2a1f9130ffcc206fbf2d9c031152f"
|
|
222
|
+
},
|
|
169
223
|
{
|
|
170
224
|
"file": "math/integration.mjs",
|
|
171
225
|
"packageFile": "dist/integration.mjs",
|
|
172
|
-
"bytes":
|
|
173
|
-
"sha256": "
|
|
226
|
+
"bytes": 5627,
|
|
227
|
+
"sha256": "932ec8827f4127313289a8823d4399594fba8c969c9a67ea326b3d8e830879ff"
|
|
174
228
|
},
|
|
175
229
|
{
|
|
176
230
|
"file": "math/markdown-it.mjs",
|
|
177
231
|
"packageFile": "dist/markdown-it.mjs",
|
|
178
|
-
"bytes":
|
|
179
|
-
"sha256": "
|
|
232
|
+
"bytes": 2836,
|
|
233
|
+
"sha256": "043d93226f051923f87bbe424ffe997e30b3feee0f51a74456adaf399d8da07c"
|
|
180
234
|
},
|
|
181
235
|
{
|
|
182
236
|
"file": "math/rehype.mjs",
|
|
183
237
|
"packageFile": "dist/rehype.mjs",
|
|
184
|
-
"bytes":
|
|
185
|
-
"sha256": "
|
|
238
|
+
"bytes": 3185,
|
|
239
|
+
"sha256": "e10dc1c2e2d5ec6dc50774639e3ba1897c111885b50e1129dd5ed8a1b393d73b"
|
|
186
240
|
},
|
|
187
241
|
{
|
|
188
242
|
"file": "math/stream.mjs",
|
|
189
243
|
"packageFile": "dist/stream.mjs",
|
|
190
|
-
"bytes":
|
|
191
|
-
"sha256": "
|
|
244
|
+
"bytes": 3795,
|
|
245
|
+
"sha256": "955eb703796d5ca11d35859c3aa9dcebeea143b02e2cc4e65df219c6a6263baf"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"file": "math/accessible.mjs",
|
|
249
|
+
"packageFile": "dist/accessible.mjs",
|
|
250
|
+
"bytes": 1214,
|
|
251
|
+
"sha256": "e56c5ca4571b618053ba33d40eafd39aa3149b007c3e54f0650f884eafc3ebad"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"file": "math/accessible.css",
|
|
255
|
+
"packageFile": "dist/accessible.css",
|
|
256
|
+
"bytes": 270,
|
|
257
|
+
"sha256": "ef27e900c08490d36b7c933bcd585b362f8813700cd9f3d728956b8c21d40b42"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"file": "math/mathml.d.ts",
|
|
261
|
+
"packageFile": "dist/mathml.d.ts",
|
|
262
|
+
"bytes": 291,
|
|
263
|
+
"sha256": "2e9eaad52c9c7ad764db55fd2c95fa7cec434cec865d368c934925f59f9abe31"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"file": "math/combined.d.ts",
|
|
267
|
+
"packageFile": "dist/combined.d.ts",
|
|
268
|
+
"bytes": 286,
|
|
269
|
+
"sha256": "5f3837d9bb0c095365a387ce88ae0c4bccd538ba75d08152a2a540c51278d7d7"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"file": "math/accessible.d.ts",
|
|
273
|
+
"packageFile": "dist/accessible.d.ts",
|
|
274
|
+
"bytes": 582,
|
|
275
|
+
"sha256": "d2d2285c084c19b87dae6c1a538b4711233dffd50098fa08bac3b8d41aa43cd3"
|
|
192
276
|
},
|
|
193
277
|
{
|
|
194
278
|
"file": "math/index.d.ts",
|
|
195
279
|
"packageFile": "dist/index.d.ts",
|
|
196
|
-
"bytes":
|
|
197
|
-
"sha256": "
|
|
280
|
+
"bytes": 2335,
|
|
281
|
+
"sha256": "cca3217cc1c5c1787b2d13fd8accf0e7fbc5bd7e55429ba8ec8657eac7eb9e18"
|
|
198
282
|
},
|
|
199
283
|
{
|
|
200
284
|
"file": "math/classic.d.ts",
|
|
201
285
|
"packageFile": "dist/classic.d.ts",
|
|
202
|
-
"bytes":
|
|
203
|
-
"sha256": "
|
|
286
|
+
"bytes": 349,
|
|
287
|
+
"sha256": "0415467509e356a5372caa0778586242de8cc0405aaa5b9db62b231d2f81de39"
|
|
204
288
|
},
|
|
205
289
|
{
|
|
206
290
|
"file": "math/delimiters.d.ts",
|
|
@@ -211,26 +295,44 @@
|
|
|
211
295
|
{
|
|
212
296
|
"file": "math/integration.d.ts",
|
|
213
297
|
"packageFile": "dist/integration.d.ts",
|
|
214
|
-
"bytes":
|
|
215
|
-
"sha256": "
|
|
298
|
+
"bytes": 1029,
|
|
299
|
+
"sha256": "8f69318a973d37f8491799c12c28ce66e9512e7f1b09009fa0601be86bdea649"
|
|
216
300
|
},
|
|
217
301
|
{
|
|
218
302
|
"file": "math/markdown-it.d.ts",
|
|
219
303
|
"packageFile": "dist/markdown-it.d.ts",
|
|
220
|
-
"bytes":
|
|
221
|
-
"sha256": "
|
|
304
|
+
"bytes": 693,
|
|
305
|
+
"sha256": "b4bf25c7a72ebb30876b66a4ce21ce293eeae3f08b8ea7962c4589a1aa7f4b80"
|
|
222
306
|
},
|
|
223
307
|
{
|
|
224
308
|
"file": "math/rehype.d.ts",
|
|
225
309
|
"packageFile": "dist/rehype.d.ts",
|
|
226
|
-
"bytes":
|
|
227
|
-
"sha256": "
|
|
310
|
+
"bytes": 560,
|
|
311
|
+
"sha256": "be3d05097c37c72cff12b46503cadfcf24efac396cb4398707136aa267f0a827"
|
|
228
312
|
},
|
|
229
313
|
{
|
|
230
314
|
"file": "math/stream.d.ts",
|
|
231
315
|
"packageFile": "dist/stream.d.ts",
|
|
232
|
-
"bytes":
|
|
233
|
-
"sha256": "
|
|
316
|
+
"bytes": 2162,
|
|
317
|
+
"sha256": "1e74da8185bbc55d6987ecaa4806a4215f5f893f49590c400c70edcb2c5c1f87"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"file": "math/examples/semantic.mjs",
|
|
321
|
+
"packageFile": "examples/semantic.mjs",
|
|
322
|
+
"bytes": 675,
|
|
323
|
+
"sha256": "dc126ece12227c92d12d247bb76ab1bcb5a04849fade307f2725b1da75070f17"
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
"file": "math/examples/accessible.html",
|
|
327
|
+
"packageFile": "examples/accessible.html",
|
|
328
|
+
"bytes": 1339,
|
|
329
|
+
"sha256": "c8d493fe7e66e299ebd90568153b2c44ba1fab31c934056ba233a06697523c9f"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"file": "math/examples/accessible.mjs",
|
|
333
|
+
"packageFile": "examples/accessible.mjs",
|
|
334
|
+
"bytes": 2077,
|
|
335
|
+
"sha256": "3c2963704cc43b92f66313b27d46c9d30678aa147c853e1b84343f3dd69b3eac"
|
|
234
336
|
},
|
|
235
337
|
{
|
|
236
338
|
"file": "math/examples/formula.mjs",
|
|
@@ -241,20 +343,20 @@
|
|
|
241
343
|
{
|
|
242
344
|
"file": "math/examples/markdown.mjs",
|
|
243
345
|
"packageFile": "examples/markdown.mjs",
|
|
244
|
-
"bytes":
|
|
245
|
-
"sha256": "
|
|
346
|
+
"bytes": 1119,
|
|
347
|
+
"sha256": "2ee7597f3f8197dccb49996bfa5a4be4050523bd80159972fd26bbf4f68f4a5d"
|
|
246
348
|
},
|
|
247
349
|
{
|
|
248
350
|
"file": "math/examples/stream.mjs",
|
|
249
351
|
"packageFile": "examples/stream.mjs",
|
|
250
|
-
"bytes":
|
|
251
|
-
"sha256": "
|
|
352
|
+
"bytes": 1439,
|
|
353
|
+
"sha256": "cf993bf0f0f74585533e2513398a75c66824776268ad235bc4e609e7b9179078"
|
|
252
354
|
},
|
|
253
355
|
{
|
|
254
356
|
"file": "math/examples/unified.mjs",
|
|
255
357
|
"packageFile": "examples/unified.mjs",
|
|
256
|
-
"bytes":
|
|
257
|
-
"sha256": "
|
|
358
|
+
"bytes": 1710,
|
|
359
|
+
"sha256": "a937ec8c1652b7f15f5cc8bf77346c74293bcd60b965a95355c4acd8da395f70"
|
|
258
360
|
},
|
|
259
361
|
{
|
|
260
362
|
"file": "math/examples/browser.html",
|
|
@@ -283,8 +385,8 @@
|
|
|
283
385
|
{
|
|
284
386
|
"file": "math/examples/README.md",
|
|
285
387
|
"packageFile": "examples/README.md",
|
|
286
|
-
"bytes":
|
|
287
|
-
"sha256": "
|
|
388
|
+
"bytes": 2881,
|
|
389
|
+
"sha256": "97d7028dc1707b309abd073e59c98f94727ba89aa00177e69ed31b0720ba4d91"
|
|
288
390
|
}
|
|
289
391
|
]
|
|
290
392
|
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# Structured mathematical output
|
|
2
|
+
|
|
3
|
+
Rapier Math serializes its existing TeX parse into Presentation MathML. Fractions, roots,
|
|
4
|
+
scripts, operators and table cells become mathematical elements that a native MathML consumer
|
|
5
|
+
can inspect. It does not infer theorem meaning, chemical identities or mathematical speech.
|
|
6
|
+
|
|
7
|
+
## Select an output
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
// This import contains the parser and serializer, with no SVG font or layout initialization.
|
|
11
|
+
import {toMathML, parse} from 'rapier-math/mathml';
|
|
12
|
+
const source = String.raw`\frac{12.5}{\sqrt[3]{x^2+1}}`;
|
|
13
|
+
const semantic = toMathML(source, {displayMode: true});
|
|
14
|
+
if (semantic.status === 'refused') console.error(semantic.errors);
|
|
15
|
+
else console.log(semantic.mathml);
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The main native entry produces SVG without importing the semantic serializer. When both outputs
|
|
19
|
+
are needed, use the explicit combined entry:
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import {renderWithMathML} from 'rapier-math/combined';
|
|
23
|
+
const result = renderWithMathML(source, {displayMode: true});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Its required `semantics` field contains the same result as `toMathML`; the combined call admits
|
|
27
|
+
and parses once. SVG errors and semantic status remain independent: MathML can represent a
|
|
28
|
+
Unicode character absent from the embedded SVG font. A successful SVG does not turn a semantic
|
|
29
|
+
refusal into success. `renderToString` returns SVG. The complete classic `RapierMath` object
|
|
30
|
+
also exposes `toMathML` and `renderWithMathML`.
|
|
31
|
+
|
|
32
|
+
The font-free entry exports `parse` for inspection as well. Parse results are ordinary,
|
|
33
|
+
detached data: changing a returned tree has no effect on subsequent renders. There is no
|
|
34
|
+
public API accepting arbitrary or modified trees for serialization. Local macros are
|
|
35
|
+
expanded by the existing parser; their expanded tree is separate from exact authored TeX.
|
|
36
|
+
|
|
37
|
+
| Result field | Meaning |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| `mathml` | One namespace-correct `math` element, including independent source annotation when admitted. |
|
|
40
|
+
| `status: "complete"` | Every encountered part has a supported structural mapping. This is a mapping claim, not an AT or mathematical-understanding claim. |
|
|
41
|
+
| `status: "presentation-fallback"` | Structure is emitted with explicit lossy presentation, domain or extension notices in `errors`. |
|
|
42
|
+
| `status: "refused"` | No equivalent expression is claimed. A bounded `merror` and source annotation are returned where possible. |
|
|
43
|
+
| `errors` | Structured fallback notices or refusal diagnostics, with the same bounded diagnostic fields as SVG rendering. |
|
|
44
|
+
| `source.encoding` | `application/x-tex`, `application/x-rapier-tex-utf16`, or `null` for omitted oversized input. |
|
|
45
|
+
| `source.omitted` | True only when source admission refused embedding. The caller still owns the original input. |
|
|
46
|
+
| `metrics` | Semantic work visits, greatest AST traversal depth, final output UTF-16 code units and emitted native link count. These are not peak-memory or DOM counts. |
|
|
47
|
+
|
|
48
|
+
## Mapping by construct
|
|
49
|
+
|
|
50
|
+
The published [MathML Core Candidate Recommendation of 24 June 2025](https://www.w3.org/TR/2025/CR-mathml-core-20250624/)
|
|
51
|
+
is the portable structural target. Extensions and lossy cases are reported explicitly.
|
|
52
|
+
|
|
53
|
+
| TeX/AST family | Mapping and qualification |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| Rows and groups | `mrow`; explicit groups stay separate. No inferred multiplication or function application is inserted. Explicit U+2061–U+2064 invisible operators remain `mo`. |
|
|
56
|
+
| Identifiers and alphabets | `mi`; Unicode mathematical alphabets reuse the SVG renderer's existing pure mapping. Roman identifiers use `mathvariant="normal"`. |
|
|
57
|
+
| Numbers | `mn` joins Unicode decimal-digit integer/decimal runs within one row and matching style. Unary signs remain `mo`. Explicit groups, spaces and style boundaries stop joining. A final directly scripted digit belongs to the complete preceding numeric token, as in `12^3`; `1{2}^3` stays grouped. Multi-dot runs are not reinterpreted as decimals. |
|
|
58
|
+
| Scientific notation | Authored `1.2e-3` remains a number, identifier and signed expression; there is no inferred exponent grammar. `1.2\times10^{-3}` preserves its explicit structure. The existing units parser's lowering remains reported as a domain fallback. |
|
|
59
|
+
| Named operators and text | Standard names and plain `operatorname` use one `mo`; ordinary multi-character text uses `mtext`. Mixed or styled operator-name content retains its nested structure and gets a fallback notice. |
|
|
60
|
+
| Fractions | `mfrac`, with numerator then denominator; zero-bar fractions and explicit fences are retained. Continued-fraction numerator alignment is a documented presentation fallback. |
|
|
61
|
+
| Roots | `msqrt` or `mroot`, with radicand before degree. |
|
|
62
|
+
| Scripts and limits | `msub`, `msup`, `msubsup`; `munder`, `mover`, `munderover` for applicable explicit/display operator limits. |
|
|
63
|
+
| Fences and accents | Explicit `mo` fences, plus under/over accent relationships. No `mfenced` dependency. |
|
|
64
|
+
| Matrices, aligned equations and cases | `mtable`/`mtr`/`mtd`, the original row/cell order and case/matrix fences. Cell alignment uses fixed CSS. Custom row gaps/baselines are reported as presentation fallback. Array insertion content remains in adjacent cells; decorative row/column rules are omitted with a notice. |
|
|
65
|
+
| Styles and spaces | `mstyle`, safe fixed CSS, Unicode alphabets and `mspace`. Text script/fraktur/double-struck requests use a disclosed MathML 3 `mathvariant` extension. |
|
|
66
|
+
| Phantom, smash and raising | `mphantom`/`mpadded`. Overlay-width adjustments retain their content with a fallback notice. Native presentation may differ from SVG. |
|
|
67
|
+
| Cancellation and generic negation overlay | MathML 3 `menclose`, with an explicit extension notice. Core-only hosts may omit the mark. Already-negated Unicode operators stay ordinary `mo`. |
|
|
68
|
+
| Rules | A decorative `mspace` with an explicit presentation notice; no additional mathematical relationship is inferred. |
|
|
69
|
+
| Explicit `mmlToken` | The authored admitted `mi`/`mn`/`mo`/`mtext` kind and token text are retained before visual literal lowering. Only the parser's admitted font variant is accepted. |
|
|
70
|
+
| Chemistry, physics and units | Existing fractions, scripts, arrows, fences and rows survive. Origin metadata triggers a domain notice; chemical elements/bonds/charges, unit identities and specialized physical meaning are not invented. |
|
|
71
|
+
| Tags and labels | Tags remain following authored content with a notice. Labels remain parser-discarded metadata: there is no equation identity, automatic numbering or cross-formula reference support. |
|
|
72
|
+
| HTTP(S) links | A native XHTML `a` inside MathML `mtext`, containing a nested MathML expression. This is a disclosed host integration fallback; see the composition contract below. Nested links and links inside phantom content refuse the semantic path. |
|
|
73
|
+
|
|
74
|
+
The parser retains only distinctions with live consumers: explicit token kind/text, operator-name
|
|
75
|
+
origin, and chemistry/physics/units/tag origin. Its visual syntax and SVG layout relationships
|
|
76
|
+
remain the same. Unsupported commands still produce parser diagnostics.
|
|
77
|
+
|
|
78
|
+
## Exact source and bounded refusal
|
|
79
|
+
|
|
80
|
+
The first child of `semantics` is the mathematical expression. For XML-valid source without
|
|
81
|
+
CR, a following `annotation encoding="application/x-tex"` keeps exact authored source
|
|
82
|
+
independently. Escaping includes numeric references for tabs and LF; BOM and supplementary
|
|
83
|
+
Unicode characters remain intact. The semantic token text is normalized presentation and is
|
|
84
|
+
never described as the original source. The [XML character and newline rules](https://www.w3.org/TR/xml/)
|
|
85
|
+
explain why ordinary escaping alone is insufficient.
|
|
86
|
+
|
|
87
|
+
Source containing CR uses `source.encoding: "application/x-rapier-tex-utf16"`, with four
|
|
88
|
+
lowercase ASCII hex digits per original UTF-16 code unit. A separate `text/plain` annotation
|
|
89
|
+
is a readable alternative, not an exact-source claim. This preserves CRLF through the actual
|
|
90
|
+
HAST-to-HTML-to-HAST pipeline: an HTML stringifier can write a decoded CR literally, which a
|
|
91
|
+
later HTML parser normalizes. The ASCII carrier survives that boundary. CR alone does not
|
|
92
|
+
make an otherwise supported expression a fallback or refusal. Recover exact source from the
|
|
93
|
+
annotation selected by `source.encoding`; when only markup remains, prefer its UTF-16
|
|
94
|
+
annotation when present, otherwise its TeX annotation. SVG uses the same carrier for CR-bearing source, preserving exact input through host
|
|
95
|
+
reserialization and later browser fitting. The source is admitted and encoded once per operation.
|
|
96
|
+
|
|
97
|
+
XML-invalid input, including isolated UTF-16 surrogates, U+0000 and U+FFFE/U+FFFF, returns
|
|
98
|
+
`refused`. A `text/plain` annotation shows explicit Unicode escapes and a separate
|
|
99
|
+
`application/x-rapier-tex-utf16` annotation contains four lowercase hex digits for every
|
|
100
|
+
original UTF-16 code unit. The same carrier used for CR is an application convention, not a
|
|
101
|
+
standard TeX media type or a claim that the readable alternative is original TeX. Source invalid in XML
|
|
102
|
+
never becomes an invalid character reference. Invalid characters produced by an admitted
|
|
103
|
+
Unicode command likewise refuse while retaining its valid authored command text.
|
|
104
|
+
|
|
105
|
+
Source longer than 1,000,000 UTF-16 code units is refused before scanning, escaping or parsing.
|
|
106
|
+
It is not truncated or embedded; `source.omitted`, the diagnostic's `sourceOmitted`, and
|
|
107
|
+
`data-math-source-omitted` make that explicit. Keep that original input with the host.
|
|
108
|
+
|
|
109
|
+
Existing parser bounds still apply: 100,000 tokens, 50,000 nodes, nesting 192 and 4096 macro
|
|
110
|
+
expansions. Serialization adds fixed limits of 100,000 work visits, traversal depth 512,
|
|
111
|
+
8 Mi presentation code units and 16 Mi complete MathML code units. Array expansions and
|
|
112
|
+
repeated insertion content count against the semantic budget. If source carriers plus
|
|
113
|
+
presentation exceed the complete-output bound, the result refuses, retains the admitted
|
|
114
|
+
source carriers and replaces the partial expression with `merror`. SVG retains its existing
|
|
115
|
+
separate limits. Combined accessible HTML has a 40 Mi code-unit bound. All budgets are local
|
|
116
|
+
to one operation; a refusal cannot poison a later render. These bounds do not measure device
|
|
117
|
+
memory or claim constant-size output.
|
|
118
|
+
|
|
119
|
+
## Usable SVG and MathML composition
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
import {renderAccessible} from 'rapier-math/accessible';
|
|
123
|
+
// Also include rapier-math/accessible.css in the host's stylesheet pipeline.
|
|
124
|
+
const result = renderAccessible(source, {displayMode: true});
|
|
125
|
+
if (result.errors.length) container.textContent = source;
|
|
126
|
+
else container.innerHTML = result.html; // only freshly generated output reaches this sink
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`renderAccessible` calls `renderWithMathML` once. It returns full standalone `svg`, the
|
|
130
|
+
semantic result, `html`, and `presentation`:
|
|
131
|
+
|
|
132
|
+
- `svg-mathml`: visual SVG is inside an `aria-hidden` wrapper; native MathML is its clipped
|
|
133
|
+
assistive sibling. There are no authored links in this branch. The semantic tree has no
|
|
134
|
+
image role, raw-TeX aria-label, `aria-hidden`, `display:none` or `visibility:hidden` override.
|
|
135
|
+
- `mathml`: authored links use visible native MathML once. Standalone SVG is still returned
|
|
136
|
+
for consumers choosing that representation, but is not inserted into the combined host.
|
|
137
|
+
Each link uses an HTTP(S) URL, a native HTML anchor, `noopener noreferrer`, and its visible
|
|
138
|
+
content as a nested mathematical expression. The destination title supplies a link-name
|
|
139
|
+
fallback in hosts that do not derive a name from MathML children; it is not generated
|
|
140
|
+
mathematical speech or a claim of a descriptive link purpose. No duplicate or clipped
|
|
141
|
+
focus target is created.
|
|
142
|
+
- `refused`: `html` is empty and `errors` explains the failure. Insert the original source
|
|
143
|
+
through a text sink. A semantic refusal is not silently downgraded to equivalent success.
|
|
144
|
+
|
|
145
|
+
This composition supplies one exposed semantic equation surface structurally. Its actual
|
|
146
|
+
announcements and link navigation still require AT acceptance. Putting an interactive link
|
|
147
|
+
under `aria-hidden` violates the [W3C focus rule](https://www.w3.org/WAI/standards-guidelines/act/rules/6cfa84/).
|
|
148
|
+
The published Core target omits native MathML links; HTML embedding uses its web integration
|
|
149
|
+
rules. A newer editor draft's MathML anchor does not establish support in a target browser.
|
|
150
|
+
Nested, phantom and empty links refuse; the serializer also checks explicit transparency
|
|
151
|
+
while allowing an opaque descendant. Unknown or host-specific color names cannot undo an explicitly transparent ancestor. These are structural checks, not a visibility guarantee
|
|
152
|
+
under arbitrary host CSS, colors or backgrounds.
|
|
153
|
+
|
|
154
|
+
The stylesheet must be retained. If it is absent or blocked, both ordinary representations
|
|
155
|
+
can become visible. Hosts that cannot include it can insert `toMathML(source).mathml` visibly
|
|
156
|
+
as their sole representation instead. Native MathML uses the host's mathematical font;
|
|
157
|
+
it does not inherit Rapier's embedded SVG outlines. Linked formulas therefore use native
|
|
158
|
+
typesetting rather than a guarantee of identical SVG appearance.
|
|
159
|
+
|
|
160
|
+
`fit`/`observe` may operate on ordinary combined output because its SVG source carrier remains
|
|
161
|
+
intact; they adjust only SVG geometry. Linked native MathML has no SVG to fit. Do not change
|
|
162
|
+
source on one side of a combined formula: regenerate the whole result. Stop observations
|
|
163
|
+
before replacement and on unmount; no semantic timers, IDs or retained formula caches exist.
|
|
164
|
+
For SSR, emit the same source/options and stylesheet; initial MathML needs no client code.
|
|
165
|
+
|
|
166
|
+
The [accessible browser example](../examples/accessible.html) keeps editable source and generated
|
|
167
|
+
MathML available and demonstrates both representations, replacement and cleanup. The
|
|
168
|
+
[font-free example](../examples/semantic.mjs) runs in Node, SSR or a module worker.
|
|
169
|
+
|
|
170
|
+
A host HTML link can wrap an ordinary `svg-mathml` result to link the whole formula while
|
|
171
|
+
preserving its SVG appearance. Put the anchor outside both composition siblings and provide
|
|
172
|
+
an authored link-purpose name, such as `aria-label="Open the derivation"`, or a meaningful
|
|
173
|
+
link title. Native MathML children can leave an otherwise unnamed host link blank in a
|
|
174
|
+
browser's accessibility tree. For accessible output the rehype adapter retains an existing
|
|
175
|
+
`aria-label`, `aria-labelledby` or title; otherwise it supplies the existing destination as
|
|
176
|
+
a title fallback. This preserves the native mathematical subtree without synthesizing
|
|
177
|
+
speech. A URL fallback is not a substitute for the author's meaningful link-purpose name.
|
|
178
|
+
Direct `renderAccessible` users must name any containing host anchor themselves. Do not nest
|
|
179
|
+
an internally linked formula inside another link. The adapters retain the outer host link
|
|
180
|
+
and leave such a formula as source with a `nested-link` diagnostic. Host grammar still applies:
|
|
181
|
+
markdown-it keeps math in link labels literal; a remark-math/rehype pipeline can admit it.
|
|
182
|
+
|
|
183
|
+
## Markdown, sanitizer and CSP boundaries
|
|
184
|
+
|
|
185
|
+
The neutral markdown-it and rehype adapters accept `accessible: true`. Include the same CSS.
|
|
186
|
+
Their document output budget counts the complete inserted HTML, including semantic annotations and every cache hit;
|
|
187
|
+
semantic refusal leaves source in the host. Original Markdown and diagnostic `mathSource` remain
|
|
188
|
+
the exact fallback authority: HTML text alone can normalize CR or replace invalid Unicode code units. Their parser grammar and lifetime ownership do not
|
|
189
|
+
change. Each inserted occurrence counts against its document's output budget.
|
|
190
|
+
|
|
191
|
+
For rehype, retain the documented order: host parsing, `rehype-sanitize`, this math adapter,
|
|
192
|
+
then serialization. The adapter materializes only newly generated output. If a host sanitizes
|
|
193
|
+
again afterward, its policy must explicitly retain the required MathML namespace/elements,
|
|
194
|
+
source annotations, generated styles, classes and native links. Do not globally allow arbitrary
|
|
195
|
+
authored SVG or HTML. HTML serialization is not a replacement for retaining original Markdown.
|
|
196
|
+
|
|
197
|
+
The example uses an external stylesheet/module and permits generated style attributes. A CSP
|
|
198
|
+
forbidding all inline style attributes cannot reproduce all SVG or MathML presentation. Core
|
|
199
|
+
structure may survive, but that is not a claim of unchanged presentation. The package creates
|
|
200
|
+
no Trusted Types policy; string insertion and SVG fitting have the same TrustedHTML limitations
|
|
201
|
+
as the existing browser API. Exact HTTP(S) link destinations carry no fetch authority until
|
|
202
|
+
the person activates them; no formula rendering request performs a network fetch.
|
|
203
|
+
|
|
204
|
+
## Assistive-technology acceptance
|
|
205
|
+
|
|
206
|
+
Generated MathML, strict XML parsing, HAST inspection and DOM/ARIA checks establish structure
|
|
207
|
+
and custody. They do not establish speech output, mathematical navigation or screen-reader
|
|
208
|
+
parity. No native browser/screen-reader stack is claimed as tested by these checks.
|
|
209
|
+
|
|
210
|
+
For each supported host, record the actual OS, browser, screen reader, math provider, versions
|
|
211
|
+
and speech/braille settings. Read a sentence with inline math, a nested fraction/root, a matrix
|
|
212
|
+
and cases expression, and a linked fraction. Check reading order, access to numerator and
|
|
213
|
+
denominator, root degree and table cells, a single intended equation announcement, one visible
|
|
214
|
+
link focus target, link activation and source edit/copy. Repeat after replacement and cleanup.
|
|
215
|
+
These steps are manual acceptance, not an automated pass:
|
|
216
|
+
|
|
217
|
+
- [NVDA's mathematical-content guide](https://download.nvaccess.org/documentation/userGuide.html):
|
|
218
|
+
use the installed provider and recorded browser; enter math from browse mode and inspect
|
|
219
|
+
its nested parts, then return to the surrounding sentence.
|
|
220
|
+
- [JAWS Math Viewer guidance](https://support.freedomscientific.com/SurfsUp/24-MathML.htm):
|
|
221
|
+
enter its viewer, inspect peers and nested structure, return and activate the native link.
|
|
222
|
+
- [VoiceOver mathematical-equation guidance for iPhone](https://support.apple.com/en-au/guide/iphone/iphe4ee74be8/27/ios/27):
|
|
223
|
+
explore the expression at different granularities and verify nested math within a link.
|
|
224
|
+
Qualify macOS/Safari separately with its actual VoiceOver controls.
|
|
225
|
+
|
|
226
|
+
Run `node tests/semantics.mjs` from the package for the focused structural/source corpus.
|
|
227
|
+
This optional development check requires Python 3 with `lxml` for strict XML verification;
|
|
228
|
+
the runtime package itself has no dependency on Python, `lxml` or an XML parser.
|
package/examples/README.md
CHANGED
|
@@ -9,6 +9,9 @@ and run `unified.mjs`. The remark example uses remark's syntax; it does not reco
|
|
|
9
9
|
|
|
10
10
|
Serve the package directory over HTTP and open `examples/browser.html`. Its external module imports the
|
|
11
11
|
installed ESM renderer, fits the output and releases observation before replacement and on page exit.
|
|
12
|
+
Keep both `dist/` and `src/` when serving or copying these native-module examples.
|
|
13
|
+
For a one-file alternative, copy `dist/rapier-math.js`, load it with a classic script tag
|
|
14
|
+
and call `globalThis.RapierMath.renderToString(source)`; do not copy only `dist/index.mjs`.
|
|
12
15
|
Start `new Worker('./worker.mjs', {type: 'module'})` from this directory and post `{id, source}`.
|
|
13
16
|
Use an id owned by the current message and ignore stale replies. Workers render SVG; they do not call `observe`.
|
|
14
17
|
|
|
@@ -18,8 +21,18 @@ Use an id owned by the current message and ignore stale replies. Workers render
|
|
|
18
21
|
For streamed UTF-8, use `TextDecoderStream` or `decoder.decode(bytes, {stream: true})` and flush the decoder
|
|
19
22
|
at EOF. Feed decoded strings into one stream per message. Append incoming chunks to a text node for immediate
|
|
20
23
|
literal progress, and replace the whole preview when `write` returns a snapshot. Replace it with `finish()` at EOF.
|
|
21
|
-
Do not concatenate transport data into HTML.
|
|
22
|
-
|
|
24
|
+
Do not concatenate transport data into HTML. Pass the callback's session through `env.rapierMathSession` or
|
|
25
|
+
VFile `data.rapierMathSession` to reuse formulas. On cancellation call `abort`. For replacement, cancel transport
|
|
26
|
+
and use the new handle returned by `stream = stream.reset()`. Each producer captures its own handle, so stale
|
|
27
|
+
writes/finish calls on the old handle refuse. A failed render releases reusable artifacts but keeps accepted
|
|
28
|
+
source for an explicit `finish()` retry; abort in a final cleanup if the host will not retry.
|
|
23
29
|
|
|
24
30
|
The examples retain the original source as the editable/copyable authority. Markdown hosts can normalize
|
|
25
31
|
newlines or escapes in their syntax nodes; an HTML serialization is not an exact source archive.
|
|
32
|
+
|
|
33
|
+
## Structured and accessible formulas
|
|
34
|
+
|
|
35
|
+
Run `node examples/semantic.mjs` for font-free MathML. Serve the package root locally and open
|
|
36
|
+
`examples/accessible.html` for source replacement, generated MathML, cleanup, CSP and the two
|
|
37
|
+
link compositions. The external stylesheet must load. General internal links use native MathML;
|
|
38
|
+
a host link around a complete ordinary formula preserves SVG. See [semantic contracts](../docs/semantics.md).
|