rapier-math 0.0.0-stage → 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,484 @@
1
+ Rapier Math
2
+
3
+ The renderer and build tools are MIT-licensed. The embedded Latin Modern Math outlines and metrics
4
+ are licensed separately under the GUST Font License. Both grants apply to this distribution.
5
+
6
+ MIT License
7
+
8
+ Copyright (c) 2026 Jack Skipworth
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Copyright 2012--2014 for Latin Modern Math OTF by B. Jackowski, P. Strzelczyk and P. Pianowski (on behalf of TeX users groups). This work is released under the GUST Font License -- see http://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt for details.
29
+
30
+ Rapier math font data, derived from Latin Modern Math 1.959.
31
+ Changes: SVG outline conversion, character and MATH data extraction,
32
+ optical-form closure, derived contour profiles and lossless path packing.
33
+ Original outlines are unchanged. Hinting and text shaping tables are omitted.
34
+ The font authors do not maintain this conversion.
35
+ Complete original work: https://mirrors.ctan.org/fonts/lm-math.zip
36
+ Conversion details: FONT-SOURCE.md.
37
+
38
+ % This is a preliminary version (2006-09-30), barring acceptance from
39
+ % the LaTeX Project Team and other feedback, of the GUST Font License.
40
+ % (GUST is the Polish TeX Users Group, http://www.gust.org.pl)
41
+ %
42
+ % For the most recent version of this license see
43
+ % http://www.gust.org.pl/fonts/licenses/GUST-FONT-LICENSE.txt
44
+ % or
45
+ % http://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt
46
+ %
47
+ % This work may be distributed and/or modified under the conditions
48
+ % of the LaTeX Project Public License, either version 1.3c of this
49
+ % license or (at your option) any later version.
50
+ %
51
+ % Please also observe the following clause:
52
+ % 1) it is requested, but not legally required, that derived works be
53
+ % distributed only after changing the names of the fonts comprising this
54
+ % work and given in an accompanying "manifest", and that the
55
+ % files comprising the Work, as listed in the manifest, also be given
56
+ % new names. Any exceptions to this request are also given in the
57
+ % manifest.
58
+ %
59
+ % We recommend the manifest be given in a separate file named
60
+ % MANIFEST-<fontid>.txt, where <fontid> is some unique identification
61
+ % of the font family. If a separate "readme" file accompanies the Work,
62
+ % we recommend a name of the form README-<fontid>.txt.
63
+ %
64
+ % The latest version of the LaTeX Project Public License is in
65
+ % http://www.latex-project.org/lppl.txt and version 1.3c or later
66
+ % is part of all distributions of LaTeX version 2006/05/20 or later.
67
+
68
+
69
+ The LaTeX Project Public License
70
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
71
+
72
+ LPPL Version 1.3c 2008-05-04
73
+
74
+ Copyright 1999 2002-2008 LaTeX3 Project
75
+ Everyone is allowed to distribute verbatim copies of this
76
+ license document, but modification of it is not allowed.
77
+
78
+
79
+ PREAMBLE
80
+ ========
81
+
82
+ The LaTeX Project Public License (LPPL) is the primary license under
83
+ which the LaTeX kernel and the base LaTeX packages are distributed.
84
+
85
+ You may use this license for any work of which you hold the copyright
86
+ and which you wish to distribute. This license may be particularly
87
+ suitable if your work is TeX-related (such as a LaTeX package), but
88
+ it is written in such a way that you can use it even if your work is
89
+ unrelated to TeX.
90
+
91
+ The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE',
92
+ below, gives instructions, examples, and recommendations for authors
93
+ who are considering distributing their works under this license.
94
+
95
+ This license gives conditions under which a work may be distributed
96
+ and modified, as well as conditions under which modified versions of
97
+ that work may be distributed.
98
+
99
+ We, the LaTeX3 Project, believe that the conditions below give you
100
+ the freedom to make and distribute modified versions of your work
101
+ that conform with whatever technical specifications you wish while
102
+ maintaining the availability, integrity, and reliability of
103
+ that work. If you do not see how to achieve your goal while
104
+ meeting these conditions, then read the document `cfgguide.tex'
105
+ and `modguide.tex' in the base LaTeX distribution for suggestions.
106
+
107
+
108
+ DEFINITIONS
109
+ ===========
110
+
111
+ In this license document the following terms are used:
112
+
113
+ `Work'
114
+ Any work being distributed under this License.
115
+
116
+ `Derived Work'
117
+ Any work that under any applicable law is derived from the Work.
118
+
119
+ `Modification'
120
+ Any procedure that produces a Derived Work under any applicable
121
+ law -- for example, the production of a file containing an
122
+ original file associated with the Work or a significant portion of
123
+ such a file, either verbatim or with modifications and/or
124
+ translated into another language.
125
+
126
+ `Modify'
127
+ To apply any procedure that produces a Derived Work under any
128
+ applicable law.
129
+
130
+ `Distribution'
131
+ Making copies of the Work available from one person to another, in
132
+ whole or in part. Distribution includes (but is not limited to)
133
+ making any electronic components of the Work accessible by
134
+ file transfer protocols such as FTP or HTTP or by shared file
135
+ systems such as Sun's Network File System (NFS).
136
+
137
+ `Compiled Work'
138
+ A version of the Work that has been processed into a form where it
139
+ is directly usable on a computer system. This processing may
140
+ include using installation facilities provided by the Work,
141
+ transformations of the Work, copying of components of the Work, or
142
+ other activities. Note that modification of any installation
143
+ facilities provided by the Work constitutes modification of the Work.
144
+
145
+ `Current Maintainer'
146
+ A person or persons nominated as such within the Work. If there is
147
+ no such explicit nomination then it is the `Copyright Holder' under
148
+ any applicable law.
149
+
150
+ `Base Interpreter'
151
+ A program or process that is normally needed for running or
152
+ interpreting a part or the whole of the Work.
153
+
154
+ A Base Interpreter may depend on external components but these
155
+ are not considered part of the Base Interpreter provided that each
156
+ external component clearly identifies itself whenever it is used
157
+ interactively. Unless explicitly specified when applying the
158
+ license to the Work, the only applicable Base Interpreter is a
159
+ `LaTeX-Format' or in the case of files belonging to the
160
+ `LaTeX-format' a program implementing the `TeX language'.
161
+
162
+
163
+
164
+ CONDITIONS ON DISTRIBUTION AND MODIFICATION
165
+ ===========================================
166
+
167
+ 1. Activities other than distribution and/or modification of the Work
168
+ are not covered by this license; they are outside its scope. In
169
+ particular, the act of running the Work is not restricted and no
170
+ requirements are made concerning any offers of support for the Work.
171
+
172
+ 2. You may distribute a complete, unmodified copy of the Work as you
173
+ received it. Distribution of only part of the Work is considered
174
+ modification of the Work, and no right to distribute such a Derived
175
+ Work may be assumed under the terms of this clause.
176
+
177
+ 3. You may distribute a Compiled Work that has been generated from a
178
+ complete, unmodified copy of the Work as distributed under Clause 2
179
+ above, as long as that Compiled Work is distributed in such a way that
180
+ the recipients may install the Compiled Work on their system exactly
181
+ as it would have been installed if they generated a Compiled Work
182
+ directly from the Work.
183
+
184
+ 4. If you are the Current Maintainer of the Work, you may, without
185
+ restriction, modify the Work, thus creating a Derived Work. You may
186
+ also distribute the Derived Work without restriction, including
187
+ Compiled Works generated from the Derived Work. Derived Works
188
+ distributed in this manner by the Current Maintainer are considered to
189
+ be updated versions of the Work.
190
+
191
+ 5. If you are not the Current Maintainer of the Work, you may modify
192
+ your copy of the Work, thus creating a Derived Work based on the Work,
193
+ and compile this Derived Work, thus creating a Compiled Work based on
194
+ the Derived Work.
195
+
196
+ 6. If you are not the Current Maintainer of the Work, you may
197
+ distribute a Derived Work provided the following conditions are met
198
+ for every component of the Work unless that component clearly states
199
+ in the copyright notice that it is exempt from that condition. Only
200
+ the Current Maintainer is allowed to add such statements of exemption
201
+ to a component of the Work.
202
+
203
+ a. If a component of this Derived Work can be a direct replacement
204
+ for a component of the Work when that component is used with the
205
+ Base Interpreter, then, wherever this component of the Work
206
+ identifies itself to the user when used interactively with that
207
+ Base Interpreter, the replacement component of this Derived Work
208
+ clearly and unambiguously identifies itself as a modified version
209
+ of this component to the user when used interactively with that
210
+ Base Interpreter.
211
+
212
+ b. Every component of the Derived Work contains prominent notices
213
+ detailing the nature of the changes to that component, or a
214
+ prominent reference to another file that is distributed as part
215
+ of the Derived Work and that contains a complete and accurate log
216
+ of the changes.
217
+
218
+ c. No information in the Derived Work implies that any persons,
219
+ including (but not limited to) the authors of the original version
220
+ of the Work, provide any support, including (but not limited to)
221
+ the reporting and handling of errors, to recipients of the
222
+ Derived Work unless those persons have stated explicitly that
223
+ they do provide such support for the Derived Work.
224
+
225
+ d. You distribute at least one of the following with the Derived Work:
226
+
227
+ 1. A complete, unmodified copy of the Work;
228
+ if your distribution of a modified component is made by
229
+ offering access to copy the modified component from a
230
+ designated place, then offering equivalent access to copy
231
+ the Work from the same or some similar place meets this
232
+ condition, even though third parties are not compelled to
233
+ copy the Work along with the modified component;
234
+
235
+ 2. Information that is sufficient to obtain a complete,
236
+ unmodified copy of the Work.
237
+
238
+ 7. If you are not the Current Maintainer of the Work, you may
239
+ distribute a Compiled Work generated from a Derived Work, as long as
240
+ the Derived Work is distributed to all recipients of the Compiled
241
+ Work, and as long as the conditions of Clause 6, above, are met with
242
+ regard to the Derived Work.
243
+
244
+ 8. The conditions above are not intended to prohibit, and hence do not
245
+ apply to, the modification, by any method, of any component so that it
246
+ becomes identical to an updated version of that component of the Work as
247
+ it is distributed by the Current Maintainer under Clause 4, above.
248
+
249
+ 9. Distribution of the Work or any Derived Work in an alternative
250
+ format, where the Work or that Derived Work (in whole or in part) is
251
+ then produced by applying some process to that format, does not relax or
252
+ nullify any sections of this license as they pertain to the results of
253
+ applying that process.
254
+
255
+ 10. a. A Derived Work may be distributed under a different license
256
+ provided that license itself honors the conditions listed in
257
+ Clause 6 above, in regard to the Work, though it does not have
258
+ to honor the rest of the conditions in this license.
259
+
260
+ b. If a Derived Work is distributed under a different license, that
261
+ Derived Work must provide sufficient documentation as part of
262
+ itself to allow each recipient of that Derived Work to honor the
263
+ restrictions in Clause 6 above, concerning changes from the Work.
264
+
265
+ 11. This license places no restrictions on works that are unrelated to
266
+ the Work, nor does this license place any restrictions on aggregating
267
+ such works with the Work by any means.
268
+
269
+ 12. Nothing in this license is intended to, or may be used to, prevent
270
+ complete compliance by all parties with all applicable laws.
271
+
272
+
273
+ NO WARRANTY
274
+ ===========
275
+
276
+ There is no warranty for the Work. Except when otherwise stated in
277
+ writing, the Copyright Holder provides the Work `as is', without
278
+ warranty of any kind, either expressed or implied, including, but not
279
+ limited to, the implied warranties of merchantability and fitness for a
280
+ particular purpose. The entire risk as to the quality and performance
281
+ of the Work is with you. Should the Work prove defective, you assume
282
+ the cost of all necessary servicing, repair, or correction.
283
+
284
+ In no event unless required by applicable law or agreed to in writing
285
+ will The Copyright Holder, or any author named in the components of the
286
+ Work, or any other party who may distribute and/or modify the Work as
287
+ permitted above, be liable to you for damages, including any general,
288
+ special, incidental or consequential damages arising out of any use of
289
+ the Work or out of inability to use the Work (including, but not limited
290
+ to, loss of data, data being rendered inaccurate, or losses sustained by
291
+ anyone as a result of any failure of the Work to operate with any other
292
+ programs), even if the Copyright Holder or said author or said other
293
+ party has been advised of the possibility of such damages.
294
+
295
+
296
+ MAINTENANCE OF THE WORK
297
+ =======================
298
+
299
+ The Work has the status `author-maintained' if the Copyright Holder
300
+ explicitly and prominently states near the primary copyright notice in
301
+ the Work that the Work can only be maintained by the Copyright Holder
302
+ or simply that it is `author-maintained'.
303
+
304
+ The Work has the status `maintained' if there is a Current Maintainer
305
+ who has indicated in the Work that they are willing to receive error
306
+ reports for the Work (for example, by supplying a valid e-mail
307
+ address). It is not required for the Current Maintainer to acknowledge
308
+ or act upon these error reports.
309
+
310
+ The Work changes from status `maintained' to `unmaintained' if there
311
+ is no Current Maintainer, or the person stated to be Current
312
+ Maintainer of the work cannot be reached through the indicated means
313
+ of communication for a period of six months, and there are no other
314
+ significant signs of active maintenance.
315
+
316
+ You can become the Current Maintainer of the Work by agreement with
317
+ any existing Current Maintainer to take over this role.
318
+
319
+ If the Work is unmaintained, you can become the Current Maintainer of
320
+ the Work through the following steps:
321
+
322
+ 1. Make a reasonable attempt to trace the Current Maintainer (and
323
+ the Copyright Holder, if the two differ) through the means of
324
+ an Internet or similar search.
325
+
326
+ 2. If this search is successful, then enquire whether the Work
327
+ is still maintained.
328
+
329
+ a. If it is being maintained, then ask the Current Maintainer
330
+ to update their communication data within one month.
331
+
332
+ b. If the search is unsuccessful or no action to resume active
333
+ maintenance is taken by the Current Maintainer, then announce
334
+ within the pertinent community your intention to take over
335
+ maintenance. (If the Work is a LaTeX work, this could be
336
+ done, for example, by posting to comp.text.tex.)
337
+
338
+ 3a. If the Current Maintainer is reachable and agrees to pass
339
+ maintenance of the Work to you, then this takes effect
340
+ immediately upon announcement.
341
+
342
+ b. If the Current Maintainer is not reachable and the Copyright
343
+ Holder agrees that maintenance of the Work be passed to you,
344
+ then this takes effect immediately upon announcement.
345
+
346
+ 4. If you make an `intention announcement' as described in 2b. above
347
+ and after three months your intention is challenged neither by
348
+ the Current Maintainer nor by the Copyright Holder nor by other
349
+ people, then you may arrange for the Work to be changed so as
350
+ to name you as the (new) Current Maintainer.
351
+
352
+ 5. If the previously unreachable Current Maintainer becomes
353
+ reachable once more within three months of a change completed
354
+ under the terms of 3b) or 4), then that Current Maintainer must
355
+ become or remain the Current Maintainer upon request provided
356
+ they then update their communication data within one month.
357
+
358
+ A change in the Current Maintainer does not, of itself, alter the fact
359
+ that the Work is distributed under the LPPL license.
360
+
361
+ If you become the Current Maintainer of the Work, you should
362
+ immediately provide, within the Work, a prominent and unambiguous
363
+ statement of your status as Current Maintainer. You should also
364
+ announce your new status to the same pertinent community as
365
+ in 2b) above.
366
+
367
+
368
+ WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE
369
+ ======================================================
370
+
371
+ This section contains important instructions, examples, and
372
+ recommendations for authors who are considering distributing their
373
+ works under this license. These authors are addressed as `you' in
374
+ this section.
375
+
376
+ Choosing This License or Another License
377
+ ----------------------------------------
378
+
379
+ If for any part of your work you want or need to use *distribution*
380
+ conditions that differ significantly from those in this license, then
381
+ do not refer to this license anywhere in your work but, instead,
382
+ distribute your work under a different license. You may use the text
383
+ of this license as a model for your own license, but your license
384
+ should not refer to the LPPL or otherwise give the impression that
385
+ your work is distributed under the LPPL.
386
+
387
+ The document `modguide.tex' in the base LaTeX distribution explains
388
+ the motivation behind the conditions of this license. It explains,
389
+ for example, why distributing LaTeX under the GNU General Public
390
+ License (GPL) was considered inappropriate. Even if your work is
391
+ unrelated to LaTeX, the discussion in `modguide.tex' may still be
392
+ relevant, and authors intending to distribute their works under any
393
+ license are encouraged to read it.
394
+
395
+ A Recommendation on Modification Without Distribution
396
+ -----------------------------------------------------
397
+
398
+ It is wise never to modify a component of the Work, even for your own
399
+ personal use, without also meeting the above conditions for
400
+ distributing the modified component. While you might intend that such
401
+ modifications will never be distributed, often this will happen by
402
+ accident -- you may forget that you have modified that component; or
403
+ it may not occur to you when allowing others to access the modified
404
+ version that you are thus distributing it and violating the conditions
405
+ of this license in ways that could have legal implications and, worse,
406
+ cause problems for the community. It is therefore usually in your
407
+ best interest to keep your copy of the Work identical with the public
408
+ one. Many works provide ways to control the behavior of that work
409
+ without altering any of its licensed components.
410
+
411
+ How to Use This License
412
+ -----------------------
413
+
414
+ To use this license, place in each of the components of your work both
415
+ an explicit copyright notice including your name and the year the work
416
+ was authored and/or last substantially modified. Include also a
417
+ statement that the distribution and/or modification of that
418
+ component is constrained by the conditions in this license.
419
+
420
+ Here is an example of such a notice and statement:
421
+
422
+ %% pig.dtx
423
+ %% Copyright 2008 M. Y. Name
424
+ %
425
+ % This work may be distributed and/or modified under the
426
+ % conditions of the LaTeX Project Public License, either version 1.3
427
+ % of this license or (at your option) any later version.
428
+ % The latest version of this license is in
429
+ % https://www.latex-project.org/lppl.txt
430
+ % and version 1.3c or later is part of all distributions of LaTeX
431
+ % version 2008 or later.
432
+ %
433
+ % This work has the LPPL maintenance status `maintained'.
434
+ %
435
+ % The Current Maintainer of this work is M. Y. Name.
436
+ %
437
+ % This work consists of the files pig.dtx and pig.ins
438
+ % and the derived file pig.sty.
439
+
440
+ Given such a notice and statement in a file, the conditions
441
+ given in this license document would apply, with the `Work' referring
442
+ to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being
443
+ generated from `pig.dtx' using `pig.ins'), the `Base Interpreter'
444
+ referring to any `LaTeX-Format', and both `Copyright Holder' and
445
+ `Current Maintainer' referring to the person `M. Y. Name'.
446
+
447
+ If you do not want the Maintenance section of LPPL to apply to your
448
+ Work, change `maintained' above into `author-maintained'.
449
+ However, we recommend that you use `maintained', as the Maintenance
450
+ section was added in order to ensure that your Work remains useful to
451
+ the community even when you can no longer maintain and support it
452
+ yourself.
453
+
454
+ Derived Works That Are Not Replacements
455
+ ---------------------------------------
456
+
457
+ Several clauses of the LPPL specify means to provide reliability and
458
+ stability for the user community. They therefore concern themselves
459
+ with the case that a Derived Work is intended to be used as a
460
+ (compatible or incompatible) replacement of the original Work. If
461
+ this is not the case (e.g., if a few lines of code are reused for a
462
+ completely different task), then clauses 6b and 6d shall not apply.
463
+
464
+
465
+ Important Recommendations
466
+ -------------------------
467
+
468
+ Defining What Constitutes the Work
469
+
470
+ The LPPL requires that distributions of the Work contain all the
471
+ files of the Work. It is therefore important that you provide a
472
+ way for the licensee to determine which files constitute the Work.
473
+ This could, for example, be achieved by explicitly listing all the
474
+ files of the Work near the copyright notice of each file or by
475
+ using a line such as:
476
+
477
+ % This work consists of all files listed in manifest.txt.
478
+
479
+ in that place. In the absence of an unequivocal list it might be
480
+ impossible for the licensee to determine what is considered by you
481
+ to comprise the Work and, in such a case, the licensee would be
482
+ entitled to make reasonable conjectures as to which files comprise
483
+ the Work.
484
+
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jack Skipworth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,111 @@
1
- # Temporary Holding Version
1
+ # Rapier Math
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ TeX-to-SVG maths with embedded Latin Modern outlines. Synchronous, offline and self-contained: no runtime
4
+ dependencies, DOM, font installation or network request is needed to render a formula.
5
+
6
+ ## Install
7
+
8
+ ```sh
9
+ npm install rapier-math
10
+ ```
11
+
12
+ ```js
13
+ import {render, renderToString} from 'rapier-math';
14
+
15
+ const result = render(String.raw`\frac{-b \pm \sqrt{b^2-4ac}}{2a}`, {displayMode: true});
16
+ if (result.errors.length) console.error(result.errors);
17
+ const svg = renderToString(String.raw`E = mc^2`);
18
+ ```
19
+
20
+ ES modules work in browsers, workers and server JavaScript runtimes. The default export also provides the
21
+ same API as named exports. Importing the module does not install a global or access the DOM.
22
+
23
+ ## Browser
24
+
25
+ Serve `index.mjs` from this package alongside your page:
26
+
27
+ ```html
28
+ <div id="equation"></div>
29
+ <script type="module">
30
+ import {render, observe} from './index.mjs';
31
+ const result = render(String.raw`\int_0^1 x^2\,dx = \frac{1}{3}`, {displayMode: true});
32
+ const container = document.querySelector('#equation');
33
+ container.innerHTML = result.svg;
34
+ const stop = observe(container);
35
+ // Call stop() when this container is no longer observed.
36
+ </script>
37
+ ```
38
+
39
+ For a classic script, load `rapier-math-1.0.1.js` and call `globalThis.RapierMath.render(tex)`.
40
+ The classic payload is 803451 bytes (496298 bytes gzip); it is the same renderer
41
+ used by Rapier's optional maths plug-in. Its SHA-384 is `1kdn6mohx3a5MAiwqRWY+6oviUHUheHfY1VMsxjDsUrn7woTaa7FSKo4juYtuNaF`.
42
+ To serve Rapier's plug-in from your own origin, place that classic payload beside `rapier.html` or
43
+ `rapier-document.html`, or in the reader's `plugins` directory.
44
+
45
+ ## API
46
+
47
+ | Export | Result |
48
+ | --- | --- |
49
+ | `render(tex, options?)` | `{svg, width, height, depth, lines, fitted, errors}`. Dimensions are mathematical ems. |
50
+ | `renderToString(tex, options?)` | The SVG string, including a diagnostic when rendering fails. |
51
+ | `parse(tex)` | Parsed syntax tree; throws a structured error for unsupported or invalid input. |
52
+ | `fit(container)` | One synchronous browser fitting pass; returns the number of selected formulas. |
53
+ | `observe(container)` | Observe the current formulas for column, font and theme changes; returns a cleanup function. |
54
+ | `version` | `1.0.1`. |
55
+
56
+ `displayMode: true` selects display mathematics. `maxWidth` sets an optional width in mathematical ems.
57
+ Long rows break before relations or binary operators; aligned derivations share their relation column.
58
+ An indivisible oversized group scales uniformly to fit. `fit` and `observe` need a browser DOM;
59
+ call `observe` again after replacing the formulas in a container.
60
+
61
+ For a known screen, pass `screen: {fontSize: 16, pixelRatio: 2, dark: false}`. Font size is the surrounding
62
+ text's CSS pixel size. The two numbers must be positive and finite, and `dark` must be a boolean.
63
+ Invalid device scales return an `invalid-screen` diagnostic. Omit `screen` for resolution-independent
64
+ output. SVGs match Latin Modern's x-height to Geist through the fonts' own metrics and inherit
65
+ `currentColor`; explicit TeX colors retain their authored values.
66
+
67
+ The root SVG retains exact valid XML source in `aria-label` and `title`. Source containing malformed
68
+ XML characters is represented with Unicode escapes in those alternatives, while `data-tex-utf16` stores
69
+ every original UTF-16 code unit as four hexadecimal digits. Rendering errors include `code`, `message`
70
+ and `offset`, with `command` when applicable. Check `errors` before treating a result as successful.
71
+
72
+ ## Supported mathematics
73
+
74
+ Fractions, roots, scripts, limits, matrices, arrays, aligned equations, delimiters, accents, operators,
75
+ Greek, mathematical alphabets and symbols, text, color, size and spacing commands are supported. The parser
76
+ also supports local TeX macros and selected chemistry and physics notation. Macro expansion and rendering
77
+ have bounded resource limits. HTTP and HTTPS links are allowed; executable URLs and injected HTML are refused.
78
+
79
+ This is a formula renderer, not a complete TeX document processor. Package loading, file input and arbitrary
80
+ TeX extensions are not supported. Labels do not establish cross-formula references or automatic equation
81
+ numbers. Unsupported syntax produces an explicit diagnostic. Latin Modern Math has no lowercase script
82
+ or bold-script alphabet: those lowercase requests use ordinary-letter fallbacks. SVG text alternatives
83
+ retain the TeX; this package does not produce semantic MathML.
84
+
85
+ ## Rebuild and verify
86
+
87
+ The complete renderer source and font regeneration instructions are in `src/`. No package installation
88
+ is needed to rebuild from the carried font data. Use Node 22 or later:
89
+
90
+ ```sh
91
+ node verify.mjs
92
+ node check.mjs
93
+ node src/math/package-build.mjs index.mjs
94
+ ```
95
+
96
+ `verify.mjs` checks the classic payload, source digests and complete licenses, then rebuilds the exact payload
97
+ in `src/shell/vendor/`. `check.mjs` checks the module entry, exact source alternatives, classic/module
98
+ agreement and hostile-content isolation. `package-build.mjs` rebuilds both the classic source output and
99
+ the module entry. The module carries the same renderer body with module-local exports; no dynamic evaluation
100
+ or global installation is needed.
101
+
102
+ To regenerate the font itself, follow `src/math/FONT-SOURCE.md` and run `python src/math/build-font.py`.
103
+ The source note uses `repo/` paths for the full Rapier checkout; this package uses `src/`.
104
+
105
+ ## Licenses
106
+
107
+ The renderer is MIT-licensed. Embedded Latin Modern Math 1.959 outlines and mathematical metrics use the
108
+ GUST Font License, an instance of the LaTeX Project Public License. `LICENSE` contains both complete grants;
109
+ `LICENSE-MIT` and `math-LICENSE.txt` reproduce the renderer license, and `math-font-LICENSE.txt` retains
110
+ the exact font copyright, conversion notice, GUST grant and LPPL 1.3c terms. Both payloads retain the notices.
111
+ `math-components.json` records the renderer and font as SPDX 2.3 components with the complete font grant.