rapier-math 1.1.0 → 1.1.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/README.md +23 -195
- package/{index.mjs → dist/index.mjs} +1 -1
- package/{rapier-math-1.1.0.js → dist/rapier-math.js} +1 -1
- package/{src/math/README.md → docs/api.md} +9 -9
- package/{math-components.json → docs/math-components.json} +6 -6
- package/{src/shell → docs}/math-resources.json +62 -36
- package/examples/browser.mjs +1 -1
- package/examples/worker.mjs +1 -1
- package/package.json +31 -55
- package/src/math/api.js +1 -1
- package/src/math/package-build.mjs +0 -13
- package/src/math/package-layout.mjs +17 -0
- package/src/math/package-readme.mjs +42 -5
- package/src/tools/build-math.mjs +36 -17
- package/{src/math/adoption-verify.mjs → tests/adoption.mjs} +1 -1
- package/{check.mjs → tests/check.mjs} +8 -8
- package/tests/verify.mjs +46 -0
- package/LICENSE-MIT +0 -21
- package/adoption-check.mjs +0 -149
- package/math-LICENSE.txt +0 -21
- package/math-font-LICENSE.txt +0 -457
- package/src/math/classic.d.ts +0 -4
- package/src/math/delimiters.d.ts +0 -8
- package/src/math/delimiters.mjs +0 -39
- package/src/math/examples/README.md +0 -25
- package/src/math/examples/browser.html +0 -10
- package/src/math/examples/browser.mjs +0 -24
- package/src/math/examples/formula.mjs +0 -12
- package/src/math/examples/markdown.mjs +0 -9
- package/src/math/examples/react.tsx +0 -19
- package/src/math/examples/stream.mjs +0 -19
- package/src/math/examples/unified.mjs +0 -26
- package/src/math/examples/worker.mjs +0 -7
- package/src/math/index.d.ts +0 -43
- package/src/math/integration.d.ts +0 -9
- package/src/math/integration.mjs +0 -28
- package/src/math/markdown-it.d.ts +0 -6
- package/src/math/markdown-it.mjs +0 -45
- package/src/math/markdown-rules.mjs +0 -65
- package/src/math/package-check.mjs +0 -118
- package/src/math/package-verify.mjs +0 -45
- package/src/math/rehype.d.ts +0 -6
- package/src/math/rehype.mjs +0 -37
- package/src/package.json +0 -9
- package/stream.d.ts +0 -14
- package/stream.mjs +0 -46
- package/verify.mjs +0 -45
- /package/{classic.d.ts → dist/classic.d.ts} +0 -0
- /package/{delimiters.d.ts → dist/delimiters.d.ts} +0 -0
- /package/{delimiters.mjs → dist/delimiters.mjs} +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{integration.d.ts → dist/integration.d.ts} +0 -0
- /package/{integration.mjs → dist/integration.mjs} +0 -0
- /package/{markdown-it.d.ts → dist/markdown-it.d.ts} +0 -0
- /package/{markdown-it.mjs → dist/markdown-it.mjs} +0 -0
- /package/{markdown-rules.mjs → dist/markdown-rules.mjs} +0 -0
- /package/{rehype.d.ts → dist/rehype.d.ts} +0 -0
- /package/{rehype.mjs → dist/rehype.mjs} +0 -0
- /package/{src/math → dist}/stream.d.ts +0 -0
- /package/{src/math → dist}/stream.mjs +0 -0
- /package/{src/math/FONT-SOURCE.md → docs/font-source.md} +0 -0
package/README.md
CHANGED
|
@@ -1,213 +1,41 @@
|
|
|
1
1
|
# Rapier Math
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
with no core runtime dependencies, DOM, global installation or remote font request. Optional integrations
|
|
5
|
-
keep the host's Markdown parser in charge.
|
|
3
|
+
A self-contained TeX-to-SVG renderer with Latin Modern outlines. Synchronous, no runtime downloads.
|
|
6
4
|
|
|
7
|
-
##
|
|
5
|
+
## Use
|
|
8
6
|
|
|
9
7
|
```sh
|
|
10
8
|
npm install rapier-math
|
|
11
9
|
```
|
|
12
10
|
|
|
13
11
|
```js
|
|
14
|
-
import {
|
|
15
|
-
const
|
|
16
|
-
const result = render(source, {displayMode: true});
|
|
17
|
-
if (result.errors.length) console.error(result.errors);
|
|
18
|
-
else console.log(result.svg);
|
|
12
|
+
import {renderToString} from 'rapier-math';
|
|
13
|
+
const svg = renderToString(String.raw`\frac{a}{b}`);
|
|
19
14
|
```
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
`
|
|
23
|
-
the
|
|
24
|
-
is provided. Server output needs no client renderer unless fitting or further rendering is wanted.
|
|
16
|
+
For a browser script, load [dist/rapier-math.js](dist/rapier-math.js) and use
|
|
17
|
+
`globalThis.RapierMath`. The native ESM entry is [dist/index.mjs](dist/index.mjs).
|
|
18
|
+
Both include the font and return synchronously. Type declarations accompany the runtime files.
|
|
25
19
|
|
|
26
|
-
|
|
20
|
+
- [API and integration guide](docs/api.md)
|
|
21
|
+
- [Runnable examples](examples/README.md)
|
|
22
|
+
- [Font source and regeneration](docs/font-source.md)
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
npm install markdown-it
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
```js
|
|
33
|
-
import MarkdownIt from 'markdown-it';
|
|
34
|
-
import rapierMath from 'rapier-math/markdown-it';
|
|
35
|
-
const md = new MarkdownIt({html: false}).use(rapierMath);
|
|
36
|
-
const env = {};
|
|
37
|
-
const html = md.render('Price $5. Code: `$$x$$`. Formula: \\(x^2\\).', env);
|
|
38
|
-
console.log(env.rapierMathErrors || []);
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Default delimiters are `\(...\)` (inline), `\[...\]` and `$$...$$` (display). Single `$...$` is opt-in:
|
|
42
|
-
`.use(rapierMath, {singleDollar: true})`. It cannot distinguish all currency from mathematics.
|
|
43
|
-
|
|
44
|
-
| Boundary rule | Contract |
|
|
45
|
-
| --- | --- |
|
|
46
|
-
| Escapes | An odd run of preceding backslashes escapes a delimiter; an even run does not. The body is never unescaped. |
|
|
47
|
-
| Dollar runs | Only complete runs of one or two dollars are delimiters. Three or more are literal. `\$$` is an escaped pair. |
|
|
48
|
-
| Single dollars | Nonempty body, no leading/trailing whitespace or CR/LF; a closer followed by an ASCII digit is rejected. |
|
|
49
|
-
| Other pairs | Whitespace and newlines are allowed. The first unescaped matching closer wins. No delimiter nesting. |
|
|
50
|
-
| Blocks | A display opener at the host's block start and a closer followed only by line whitespace makes a block. Otherwise it is inline content. |
|
|
51
|
-
| Incomplete input | No math node is emitted until a matching closer exists. Surrounding text stays under host control. |
|
|
52
|
-
| Protected source | Code spans, fences, indented code, link destinations, autolinks and HTML tags remain host syntax. Math in link labels is disabled. Math in image descriptions is retained as literal source in alt text. |
|
|
53
|
-
|
|
54
|
-
Use `html: false` for untrusted Markdown. If your application enables raw HTML, retain its sanitizer and
|
|
55
|
-
HTML policy. Inline HTML element contents follow the host grammar; the math adapter is not an HTML parser.
|
|
56
|
-
The `rapier-math/delimiters` export offers `createMathMatcher(source, options)(start, limit?)` for authors of
|
|
57
|
-
other host adapters. It indexes boundaries in a raw text region, returns exact UTF-16 offsets, and knows
|
|
58
|
-
nothing about Markdown structure. Do not scan rendered HTML with it.
|
|
59
|
-
|
|
60
|
-
The Rapier app explicitly keeps its established dollar-only dialect, including math in link labels.
|
|
61
|
-
The shared owner corrects escaped display closers and retains outer formula whitespace. No public
|
|
62
|
-
adapter or renderer imports the app's AGPL Markdown implementation.
|
|
63
|
-
|
|
64
|
-
## unified / remark / rehype
|
|
65
|
-
|
|
66
|
-
Use `remark-math`, `remark-rehype`, then `rehype-sanitize`, then `rapier-math/rehype`, then `rehype-stringify`.
|
|
67
|
-
The complete [unified example](examples/unified.mjs) grants only the math classes on sanitized code nodes.
|
|
68
|
-
The adapter replaces supported `language-math` + `math-inline`/`math-display` nodes with HAST parsed from
|
|
69
|
-
fresh renderer SVG. It does not turn authored raw HTML into trusted markup or loosen the global SVG sanitizer.
|
|
70
|
-
The optional `hast-util-from-html` peer is used only by this entrypoint.
|
|
71
|
-
|
|
72
|
-
Choose `remarkMath({singleDollarTextMath: false})` to avoid single-dollar ambiguity. Remark owns delimiter,
|
|
73
|
-
whitespace and code rules in this pipeline; its grammar is different from the markdown-it adapter and does
|
|
74
|
-
not enable backslash delimiters. Unsupported formulas remain copyable code and produce VFile messages
|
|
75
|
-
with `ruleId`, `mathOffset` and `mathSource`.
|
|
76
|
-
|
|
77
|
-
Both rendering adapters accept `renderOptions`, `maxFormulas` (default 1024) and `maxOutputLength` (default
|
|
78
|
-
16 Mi UTF-16 code units of successful SVG per document render). Rendering a cached markdown-it token tree
|
|
79
|
-
again starts a fresh budget; inline children share their enclosing document's budget. Exhaustion leaves subsequent source literal with
|
|
80
|
-
diagnostics. The host owns its own source, tree, prose and final HTML budgets. These are synchronous adapters.
|
|
81
|
-
|
|
82
|
-
## Streaming
|
|
83
|
-
|
|
84
|
-
```js
|
|
85
|
-
import {createMarkdownStream} from 'rapier-math/stream';
|
|
86
|
-
const stream = createMarkdownStream(source => md.render(source, {}));
|
|
87
|
-
const preview = stream.write('The answer is \\(x'); // may return null
|
|
88
|
-
stream.write('^2\\).');
|
|
89
|
-
const completed = stream.finish(); // {source, html, revision, final: true}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Use one stream per message. `write` accepts decoded strings and returns either a whole preview or `null`;
|
|
93
|
-
`finish` always runs the same batch renderer on the complete exact source. `abort` releases pending text.
|
|
94
|
-
`reset` starts a replacement and advances the revision. Cancel the old producer before reset, or reject its
|
|
95
|
-
chunks using your conversation generation. No callbacks, timers, DOM mutations or shared conversation state
|
|
96
|
-
are installed. See the [stream example](examples/stream.mjs).
|
|
97
|
-
|
|
98
|
-
Markdown references, setext headings and fences can change earlier interpretation, so previews are
|
|
99
|
-
replaceable, not committed prefixes. An open formula remains literal. Defaults: at most 1,000,000 retained
|
|
100
|
-
source code units; first preview at 256 units, then only after the source has at least doubled. Including
|
|
101
|
-
one `finish`, the total source sent to the host is less than three times final length, even if previews fail.
|
|
102
|
-
Explicit retries of `finish` are additional host calls. There is no full-prefix
|
|
103
|
-
render on every token. Late previews are consequently less frequent; show incoming chunks as text for
|
|
104
|
-
immediate progress. `previewEvery` sets the first threshold, not a fixed per-chunk interval.
|
|
105
|
-
|
|
106
|
-
Retained state is O(message length), not a claimed constant-memory Markdown parser. Stream chunks can split
|
|
107
|
-
delimiters, CRLF, escapes or surrogate pairs. Final interpretation is batch-equivalent; interim previews
|
|
108
|
-
may show an incomplete code unit. A rejected oversized chunk is not accepted or silently truncated; the
|
|
109
|
-
caller still owns it. A failed renderer leaves accumulated source available for retry or reset.
|
|
110
|
-
|
|
111
|
-
## Formula API and browser lifetime
|
|
112
|
-
|
|
113
|
-
| Export | Result |
|
|
114
|
-
| --- | --- |
|
|
115
|
-
| `render(tex, options?)` | `{svg, width, height, depth, lines, fitted, errors}`; dimensions in mathematical ems. |
|
|
116
|
-
| `renderToString(tex, options?)` | SVG, including diagnostic SVG for admitted malformed or unsupported syntax. |
|
|
117
|
-
| `parse(tex)` | Inspectable AST; throws structured errors. Internal node vocabulary can grow. |
|
|
118
|
-
| `fit(container)` | One synchronous DOM fitting pass, returning selected formula count. |
|
|
119
|
-
| `observe(container)` | Observe current formulas; returns idempotent cleanup. |
|
|
120
|
-
| `version` | The package version. Default export provides the same API. |
|
|
121
|
-
|
|
122
|
-
`displayMode`, `maxWidth` in mathematical ems, and optional `screen: {fontSize, pixelRatio, dark}` configure
|
|
123
|
-
rendering. Screen numbers must be positive finite values; `dark` must be boolean. Omit screen options for
|
|
124
|
-
SSR and the initial hydration render. Long rows break at available relations/operators; indivisible
|
|
125
|
-
oversized groups scale to fit. Fit after hydration, stop observation before replacement, then observe the
|
|
126
|
-
new formulas. Stop on unmount. [Browser](examples/browser.html), [worker](examples/worker.mjs) and
|
|
127
|
-
[React/SSR](examples/react.tsx) examples demonstrate these boundaries. React is not a package dependency.
|
|
128
|
-
|
|
129
|
-
## Errors, source and accessibility
|
|
130
|
-
|
|
131
|
-
Check `errors` before treating a formula as successful. Errors include `code`, `message`, UTF-16 `offset`
|
|
132
|
-
and sometimes `command`. Render-result messages are limited to 1024 code units plus an ellipsis and command
|
|
133
|
-
names to 128, with explicit `messageTruncated`/`commandTruncated` flags. Exact admitted source is retained
|
|
134
|
-
independently. `parse` throws the parser's details, bounded by its source admission limit. Do not use a
|
|
135
|
-
diagnostic message as a source archive.
|
|
136
|
-
|
|
137
|
-
Valid XML source is kept exactly in SVG `aria-label` and `title`, including BOM, tabs and CRLF (escaped as
|
|
138
|
-
character references). Invalid XML characters have visible Unicode escapes and a `data-tex-utf16` carrier:
|
|
139
|
-
each four hex digits represents one original UTF-16 code unit. This includes isolated surrogates. The
|
|
140
|
-
Markdown host may normalize its syntax-node content; retain the original Markdown separately. Streams
|
|
141
|
-
return the exact concatenated source, including malformed UTF-16, without normalization.
|
|
142
|
-
|
|
143
|
-
Source longer than 1,000,000 code units returns a bounded `resource-limit` diagnostic before source
|
|
144
|
-
scanning, escaping or parsing. Its error has `sourceOmitted: true` and its SVG has
|
|
145
|
-
`data-math-source-omitted="true"`; neither embeds or truncates the refused source. `renderToString` returns
|
|
146
|
-
the same diagnostic SVG. Keep the original input for editing or copying. Admitted source alternatives
|
|
147
|
-
remain exact. Other limits include 100,000 tokens, 50,000 parser nodes, depth 192, 4096 macro expansions, 100,000 layout
|
|
148
|
-
visits, 4 Mi outline characters and 8 Mi composed SVG characters. Complete returned SVG, including source
|
|
149
|
-
alternatives and diagnostics, is capped at 24 Mi UTF-16 code units. These are output/work bounds, not peak
|
|
150
|
-
heap or device-memory claims. A later good render has a fresh budget.
|
|
151
|
-
|
|
152
|
-
SVG labels contain raw TeX, not semantic MathML or mathematical speech. Ordinary equations are images in
|
|
153
|
-
the accessibility tree. Equations containing authored HTTP(S) links use a group so the links remain exposed;
|
|
154
|
-
each link is keyboard-focusable and labelled with its destination. Keep the editable source or a separate
|
|
155
|
-
copy-source affordance in your host. Full semantic navigation, speech and screen-reader parity are not
|
|
156
|
-
provided. A future semantic serializer needs an explicit AST-to-MathML mapping and assistive-technology
|
|
157
|
-
evaluation; adding a raw TeX label does not satisfy that requirement.
|
|
158
|
-
|
|
159
|
-
## Security and deployment
|
|
160
|
-
|
|
161
|
-
The renderer emits local SVG outlines, never executable HTML, remote font/image fetches or loaded TeX
|
|
162
|
-
extensions. Authored links permit only HTTP(S) and use `noopener noreferrer`. Insert only the returned
|
|
163
|
-
SVG, never concatenate TeX or arbitrary HTML into the sink. On failure, use a text node or the framework's
|
|
164
|
-
escaped text rendering. Formula safety does not sanitize surrounding Markdown.
|
|
165
|
-
|
|
166
|
-
The native ESM path needs no `eval` or `unsafe-eval`. Generated SVG does contain style attributes:
|
|
167
|
-
`script-src 'self'; style-src-attr 'unsafe-inline'; style-src-elem 'none'` permits same-origin external
|
|
168
|
-
modules and those attributes in browsers implementing CSP3. It does **not** work under a policy forbidding
|
|
169
|
-
all inline styles. `examples/browser.html` carries that policy; older browsers need their own reviewed
|
|
170
|
-
style policy. No network access is needed after local module loading; use `connect-src 'none'` if suitable.
|
|
171
|
-
|
|
172
|
-
With `require-trusted-types-for 'script'`, string HTML sinks and the DOMParser used by `fit`/`observe`
|
|
173
|
-
require TrustedHTML. The core does not create a policy, return TrustedHTML or claim fitting support under
|
|
174
|
-
that policy. Prefer server-rendered output or the structured rehype path in such applications. If the host
|
|
175
|
-
uses a policy for initial insertion, narrowly scope it to freshly generated renderer output; never use a
|
|
176
|
-
blanket identity policy for arbitrary strings. The browser/React examples assume string sinks are permitted.
|
|
177
|
-
|
|
178
|
-
## Syntax and limits
|
|
179
|
-
|
|
180
|
-
Supported: fractions, roots, scripts, limits, matrices/arrays/alignment, delimiters, accents, operators,
|
|
181
|
-
Greek and mathematical alphabets, text/color/size/spacing, local macros, and selected chemistry/physics.
|
|
182
|
-
Existing supported package names select built-in syntax; there is no external package/file loader.
|
|
183
|
-
This is not a complete TeX document engine. No automatic numbering or cross-formula reference guarantee.
|
|
184
|
-
Unsupported commands give diagnostics. Lowercase script/bold-script requests use ordinary-letter fallbacks
|
|
185
|
-
where Latin Modern lacks those alphabets. All embedded licensed outlines remain present.
|
|
186
|
-
|
|
187
|
-
## Package and proof
|
|
188
|
-
|
|
189
|
-
Declarations accompany every public entry. Formula imports do not pull in Markdown, unified or React.
|
|
190
|
-
For TypeScript, markdown-it 15 provides its own types; markdown-it 14 projects also install
|
|
191
|
-
`@types/markdown-it@14`. Use the declarations for your host version.
|
|
192
|
-
For a classic script, use `rapier-math-1.1.0.js` and `globalThis.RapierMath`.
|
|
193
|
-
The payload includes the font: it is not a few-kilobyte renderer. Payload counts below describe this
|
|
194
|
-
build, not npm tarball size or a comparison against another library.
|
|
24
|
+
## Develop
|
|
195
25
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
26
|
+
The current runtime formats live in `dist/`; editable renderer source and its build tools live in
|
|
27
|
+
`src/`. Optional adapters have one source copy in `dist/`. Examples, documentation and tests each
|
|
28
|
+
have their own directory. Only the current release is kept in this checkout.
|
|
199
29
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
size/speed superiority. Test your host's sanitizer, CSP, browser lifetime and supported formula corpus.
|
|
30
|
+
From a repository checkout, run `node tests/check.mjs` and `node tests/verify.mjs` to check the package and rebuild its exact bytes.
|
|
31
|
+
Run `node src/tools/build-math.mjs --package .` to regenerate the classic and ESM files from source.
|
|
32
|
+
Optional host checks run with `node tests/adoption.mjs` after installing the example dependencies.
|
|
204
33
|
|
|
205
|
-
##
|
|
34
|
+
## License
|
|
206
35
|
|
|
207
|
-
The renderer and
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
36
|
+
The renderer and adapters are MIT-licensed. Embedded Latin Modern Math outlines and metrics are
|
|
37
|
+
licensed under the GUST Font License. [LICENSE](LICENSE) contains both complete grants.
|
|
38
|
+
[Component provenance](docs/math-components.json) and [source hashes](docs/math-resources.json)
|
|
39
|
+
travel with the package.
|
|
211
40
|
|
|
212
|
-
|
|
213
|
-
SHA-384: `dYIPrqCf4rrTcAKw1Zzzo7vujbNtk2C7Zik/tIYOaLVT0U66WOXcGNE6waFbKych`
|
|
41
|
+
Version 1.1.1. Classic payload: 714051 bytes; gzip (level 9): 442525 bytes.
|
|
@@ -64,7 +64,7 @@ adapter or renderer imports the app's AGPL Markdown implementation.
|
|
|
64
64
|
## unified / remark / rehype
|
|
65
65
|
|
|
66
66
|
Use `remark-math`, `remark-rehype`, then `rehype-sanitize`, then `rapier-math/rehype`, then `rehype-stringify`.
|
|
67
|
-
The complete [unified example](examples/unified.mjs) grants only the math classes on sanitized code nodes.
|
|
67
|
+
The complete [unified example](../examples/unified.mjs) grants only the math classes on sanitized code nodes.
|
|
68
68
|
The adapter replaces supported `language-math` + `math-inline`/`math-display` nodes with HAST parsed from
|
|
69
69
|
fresh renderer SVG. It does not turn authored raw HTML into trusted markup or loosen the global SVG sanitizer.
|
|
70
70
|
The optional `hast-util-from-html` peer is used only by this entrypoint.
|
|
@@ -93,7 +93,7 @@ Use one stream per message. `write` accepts decoded strings and returns either a
|
|
|
93
93
|
`finish` always runs the same batch renderer on the complete exact source. `abort` releases pending text.
|
|
94
94
|
`reset` starts a replacement and advances the revision. Cancel the old producer before reset, or reject its
|
|
95
95
|
chunks using your conversation generation. No callbacks, timers, DOM mutations or shared conversation state
|
|
96
|
-
are installed. See the [stream example](examples/stream.mjs).
|
|
96
|
+
are installed. See the [stream example](../examples/stream.mjs).
|
|
97
97
|
|
|
98
98
|
Markdown references, setext headings and fences can change earlier interpretation, so previews are
|
|
99
99
|
replaceable, not committed prefixes. An open formula remains literal. Defaults: at most 1,000,000 retained
|
|
@@ -123,8 +123,8 @@ caller still owns it. A failed renderer leaves accumulated source available for
|
|
|
123
123
|
rendering. Screen numbers must be positive finite values; `dark` must be boolean. Omit screen options for
|
|
124
124
|
SSR and the initial hydration render. Long rows break at available relations/operators; indivisible
|
|
125
125
|
oversized groups scale to fit. Fit after hydration, stop observation before replacement, then observe the
|
|
126
|
-
new formulas. Stop on unmount. [Browser](examples/browser.html), [worker](examples/worker.mjs) and
|
|
127
|
-
[React/SSR](examples/react.tsx) examples demonstrate these boundaries. React is not a package dependency.
|
|
126
|
+
new formulas. Stop on unmount. [Browser](../examples/browser.html), [worker](../examples/worker.mjs) and
|
|
127
|
+
[React/SSR](../examples/react.tsx) examples demonstrate these boundaries. React is not a package dependency.
|
|
128
128
|
|
|
129
129
|
## Errors, source and accessibility
|
|
130
130
|
|
|
@@ -189,13 +189,13 @@ where Latin Modern lacks those alphabets. All embedded licensed outlines remain
|
|
|
189
189
|
Declarations accompany every public entry. Formula imports do not pull in Markdown, unified or React.
|
|
190
190
|
For TypeScript, markdown-it 15 provides its own types; markdown-it 14 projects also install
|
|
191
191
|
`@types/markdown-it@14`. Use the declarations for your host version.
|
|
192
|
-
For a classic script, use `rapier-math
|
|
192
|
+
For a classic script, use `dist/rapier-math.js` and `globalThis.RapierMath`.
|
|
193
193
|
The payload includes the font: it is not a few-kilobyte renderer. Payload counts below describe this
|
|
194
194
|
build, not npm tarball size or a comparison against another library.
|
|
195
195
|
|
|
196
|
-
Run `node verify.mjs` and `node check.mjs` from
|
|
196
|
+
Run `node tests/verify.mjs` and `node tests/check.mjs` from this checkout. The carried source rebuilds the exact
|
|
197
197
|
classic payload and ESM module; receipts also cover the adapters, declarations and examples. Follow
|
|
198
|
-
`
|
|
198
|
+
`docs/font-source.md` to regenerate font data. License and font provenance are carried with every build.
|
|
199
199
|
|
|
200
200
|
Verified-claim scope: synchronous self-contained formula rendering; opt-in Markdown integrations; bounded
|
|
201
201
|
replaceable previews with exact final source; structured diagnostics and explicit source fallback. This
|
|
@@ -205,6 +205,6 @@ size/speed superiority. Test your host's sanitizer, CSP, browser lifetime and su
|
|
|
205
205
|
## Licenses
|
|
206
206
|
|
|
207
207
|
The renderer and neutral adapters are MIT. Latin Modern Math 1.959 outlines/metrics retain the GUST Font
|
|
208
|
-
License, an instance of LPPL. `LICENSE` contains both complete grants. `LICENSE-MIT`,
|
|
209
|
-
`math-
|
|
208
|
+
License, an instance of LPPL. `LICENSE` contains both complete grants. `src/math/LICENSE-MIT`,
|
|
209
|
+
`src/math/FONT-LICENSE.txt` and the SPDX 2.3 `docs/math-components.json` retain renderer and font notices. Both payloads
|
|
210
210
|
retain complete licenses. App-specific AGPL source is not included in this package.
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"spdxVersion": "SPDX-2.3",
|
|
3
3
|
"dataLicense": "CC0-1.0",
|
|
4
4
|
"SPDXID": "SPDXRef-DOCUMENT",
|
|
5
|
-
"name": "rapier-math-1.1.
|
|
6
|
-
"documentNamespace": "https://rapier.website/spdx/rapier-math-1.1.
|
|
5
|
+
"name": "rapier-math-1.1.1",
|
|
6
|
+
"documentNamespace": "https://rapier.website/spdx/rapier-math-1.1.1-050f4ebfb7c78beaefb01c9d6aa62192fd03757fc677134850bdb1f090033b81",
|
|
7
7
|
"creationInfo": {
|
|
8
|
-
"created": "2026-10-
|
|
8
|
+
"created": "2026-10-12T17:29:00Z",
|
|
9
9
|
"creators": [
|
|
10
10
|
"Tool: rapier-math-components",
|
|
11
11
|
"Organization: rapier.website"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
{
|
|
16
16
|
"name": "rapier-math",
|
|
17
17
|
"SPDXID": "SPDXRef-rapier-math",
|
|
18
|
-
"versionInfo": "1.1.
|
|
18
|
+
"versionInfo": "1.1.1",
|
|
19
19
|
"downloadLocation": "NOASSERTION",
|
|
20
20
|
"filesAnalyzed": false,
|
|
21
21
|
"licenseConcluded": "MIT AND LicenseRef-GUST-Font-License",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"checksums": [
|
|
25
25
|
{
|
|
26
26
|
"algorithm": "SHA256",
|
|
27
|
-
"checksumValue": "
|
|
27
|
+
"checksumValue": "050f4ebfb7c78beaefb01c9d6aa62192fd03757fc677134850bdb1f090033b81"
|
|
28
28
|
}
|
|
29
29
|
]
|
|
30
30
|
},
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"checksumValue": "6075562b771f8b82f0c179e363389684f2dd09de30038269e2628e504bd7be0f"
|
|
44
44
|
}
|
|
45
45
|
],
|
|
46
|
-
"comment": "SVG outlines and OpenType MATH metrics; complete license in math-
|
|
46
|
+
"comment": "SVG outlines and OpenType MATH metrics; complete license in src/math/FONT-LICENSE.txt"
|
|
47
47
|
}
|
|
48
48
|
],
|
|
49
49
|
"hasExtractedLicensingInfos": [
|
|
@@ -1,108 +1,134 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundle": "rapier-math-1.1.
|
|
3
|
-
"
|
|
2
|
+
"bundle": "rapier-math-1.1.1.js",
|
|
3
|
+
"packageBundle": "dist/rapier-math.js",
|
|
4
|
+
"version": "1.1.1",
|
|
4
5
|
"license": "MIT AND LicenseRef-GUST-Font-License",
|
|
5
6
|
"bytes": 714051,
|
|
6
7
|
"gzipBytes": 442525,
|
|
7
|
-
"sha256": "
|
|
8
|
-
"sha384": "
|
|
8
|
+
"sha256": "050f4ebfb7c78beaefb01c9d6aa62192fd03757fc677134850bdb1f090033b81",
|
|
9
|
+
"sha384": "FnVbul5Kp18nd2S1SdMQlMPJtulZiY5ZqrRtJ8APYoP6reF9w0JRjF/qrmH9l9s0",
|
|
9
10
|
"sources": [
|
|
10
11
|
{
|
|
11
12
|
"file": "math/font.js",
|
|
13
|
+
"packageFile": "src/math/font.js",
|
|
12
14
|
"bytes": 558719,
|
|
13
15
|
"sha256": "1263135501cb049efb087975db43c0fa6d131e5deee4282d982995d4ab0884c4"
|
|
14
16
|
},
|
|
15
17
|
{
|
|
16
18
|
"file": "math/symbols.js",
|
|
19
|
+
"packageFile": "src/math/symbols.js",
|
|
17
20
|
"bytes": 8415,
|
|
18
21
|
"sha256": "80f485e8023afe3783d30c4616709e0a3b0ed0ba8a238bd818085cdd107f03ad"
|
|
19
22
|
},
|
|
20
23
|
{
|
|
21
24
|
"file": "math/parser.js",
|
|
25
|
+
"packageFile": "src/math/parser.js",
|
|
22
26
|
"bytes": 69355,
|
|
23
27
|
"sha256": "067594e1b1391a7c29b71ff51e0e812f16785e14a863dbc04069627760435633"
|
|
24
28
|
},
|
|
25
29
|
{
|
|
26
30
|
"file": "math/layout.js",
|
|
31
|
+
"packageFile": "src/math/layout.js",
|
|
27
32
|
"bytes": 37632,
|
|
28
33
|
"sha256": "84f0abeb24907f370754e30e5cf0576cb2346b941815494c9958892f3d1cc939"
|
|
29
34
|
},
|
|
30
35
|
{
|
|
31
36
|
"file": "math/fallbacks.js",
|
|
37
|
+
"packageFile": "src/math/fallbacks.js",
|
|
32
38
|
"bytes": 7953,
|
|
33
39
|
"sha256": "400c5771756d5a4d4cf431d471b33c280791ce4aa276a0fd2615d91ee88ae8ce"
|
|
34
40
|
},
|
|
35
41
|
{
|
|
36
42
|
"file": "math/responsive.js",
|
|
43
|
+
"packageFile": "src/math/responsive.js",
|
|
37
44
|
"bytes": 13566,
|
|
38
45
|
"sha256": "387e2952317ba8124bd7f56a71feb9555f3cb6081de687d79eb4c9e6cab4b6ed"
|
|
39
46
|
},
|
|
40
47
|
{
|
|
41
48
|
"file": "math/browser.js",
|
|
49
|
+
"packageFile": "src/math/browser.js",
|
|
42
50
|
"bytes": 10048,
|
|
43
51
|
"sha256": "5a9b1ee1b8c55a5560058b0fcfb5d6623f7de74e49bcb4281acdf7c97b235101"
|
|
44
52
|
},
|
|
45
53
|
{
|
|
46
54
|
"file": "math/api.js",
|
|
55
|
+
"packageFile": "src/math/api.js",
|
|
47
56
|
"bytes": 7245,
|
|
48
|
-
"sha256": "
|
|
57
|
+
"sha256": "0ad779d91a760c5dd908caf8f037df8b6db82d69cefab42bd8b5493d68f30b4e"
|
|
49
58
|
}
|
|
50
59
|
],
|
|
51
60
|
"recipe": [
|
|
52
61
|
{
|
|
53
62
|
"file": "math/build-font.py",
|
|
63
|
+
"packageFile": "src/math/build-font.py",
|
|
54
64
|
"bytes": 33369,
|
|
55
65
|
"sha256": "d54dba7b83d945da4bdeeac6a262c45d0b8f531c0801114451ac3f3d8dab9d35"
|
|
56
66
|
},
|
|
57
67
|
{
|
|
58
68
|
"file": "math/FONT-SOURCE.md",
|
|
69
|
+
"packageFile": "docs/font-source.md",
|
|
59
70
|
"bytes": 10357,
|
|
60
71
|
"sha256": "84ab319b1f9342fa08b421231965dd685063d8fd6bb8a071e1f1c186848dcdd9"
|
|
61
72
|
},
|
|
62
73
|
{
|
|
63
74
|
"file": "math/FONT-LICENSE.txt",
|
|
75
|
+
"packageFile": "src/math/FONT-LICENSE.txt",
|
|
64
76
|
"bytes": 21246,
|
|
65
77
|
"sha256": "91ded9a2a371cbeff028bfaf3bd3e97fddfb68af6f186aa261bfaff35baf800c"
|
|
66
78
|
},
|
|
67
79
|
{
|
|
68
80
|
"file": "math/package-verify.mjs",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
81
|
+
"packageFile": "tests/verify.mjs",
|
|
82
|
+
"bytes": 2972,
|
|
83
|
+
"sha256": "bb28e7ea37021ea191bd858a18beb97bb8ca14b52015dfe1e49d7d07dea60b48"
|
|
71
84
|
},
|
|
72
85
|
{
|
|
73
86
|
"file": "tools/build-math.mjs",
|
|
74
|
-
"
|
|
75
|
-
"
|
|
87
|
+
"packageFile": "src/tools/build-math.mjs",
|
|
88
|
+
"bytes": 8668,
|
|
89
|
+
"sha256": "06c6d4f0d56de87b8869bf04433b7ff8cea6f7f19e4dc7ea6a2e21279f9cb50e"
|
|
76
90
|
},
|
|
77
91
|
{
|
|
78
92
|
"file": "math/LICENSE-MIT",
|
|
93
|
+
"packageFile": "src/math/LICENSE-MIT",
|
|
79
94
|
"bytes": 1071,
|
|
80
95
|
"sha256": "a3bc5d619ab9159f4eef2924e48dfb935556f4bc163f5ea61610b66a5915de70"
|
|
81
96
|
},
|
|
82
97
|
{
|
|
83
98
|
"file": "math/adoption-verify.mjs",
|
|
84
|
-
"
|
|
85
|
-
"
|
|
99
|
+
"packageFile": "tests/adoption.mjs",
|
|
100
|
+
"bytes": 8254,
|
|
101
|
+
"sha256": "15179557c7d1bdd76ae7a06956f8be65b375f7f187940e5227baa0d4930b3b63"
|
|
86
102
|
},
|
|
87
103
|
{
|
|
88
104
|
"file": "math/package-build.mjs",
|
|
89
|
-
"
|
|
90
|
-
"
|
|
105
|
+
"packageFile": "src/math/package-build.mjs",
|
|
106
|
+
"bytes": 989,
|
|
107
|
+
"sha256": "9cbe11960f0190375c3d086e731078aab5acaaf8a5a77f83f3395ff3ba0291de"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"file": "math/package-layout.mjs",
|
|
111
|
+
"packageFile": "src/math/package-layout.mjs",
|
|
112
|
+
"bytes": 681,
|
|
113
|
+
"sha256": "a8f5bfe84dde4745c7c6fbfffa7b80766d39ec1adf727c2de59be9596711b320"
|
|
91
114
|
},
|
|
92
115
|
{
|
|
93
116
|
"file": "math/package-check.mjs",
|
|
94
|
-
"
|
|
95
|
-
"
|
|
117
|
+
"packageFile": "tests/check.mjs",
|
|
118
|
+
"bytes": 7455,
|
|
119
|
+
"sha256": "4df4f81251c66473a2ea491072364c68761da7313fff36a19e82e3313220ce26"
|
|
96
120
|
},
|
|
97
121
|
{
|
|
98
122
|
"file": "math/package-readme.mjs",
|
|
99
|
-
"
|
|
100
|
-
"
|
|
123
|
+
"packageFile": "src/math/package-readme.mjs",
|
|
124
|
+
"bytes": 1853,
|
|
125
|
+
"sha256": "9408728370c81d463794ef67380c587748ed1b1633b56b1d1a2b33d9a95b3986"
|
|
101
126
|
},
|
|
102
127
|
{
|
|
103
128
|
"file": "math/README.md",
|
|
104
|
-
"
|
|
105
|
-
"
|
|
129
|
+
"packageFile": "docs/api.md",
|
|
130
|
+
"bytes": 14103,
|
|
131
|
+
"sha256": "83368017d04a50a3d13e6e2e070322a5eef4bf8f54f521bd7ff061e186afc3f5"
|
|
106
132
|
}
|
|
107
133
|
],
|
|
108
134
|
"components": [
|
|
@@ -130,79 +156,79 @@
|
|
|
130
156
|
"adoption": [
|
|
131
157
|
{
|
|
132
158
|
"file": "math/delimiters.mjs",
|
|
133
|
-
"packageFile": "delimiters.mjs",
|
|
159
|
+
"packageFile": "dist/delimiters.mjs",
|
|
134
160
|
"bytes": 1945,
|
|
135
161
|
"sha256": "2847d23ba78534b32348d5e642ded601e4f6fd9c41e10d80c46955d440d24eba"
|
|
136
162
|
},
|
|
137
163
|
{
|
|
138
164
|
"file": "math/markdown-rules.mjs",
|
|
139
|
-
"packageFile": "markdown-rules.mjs",
|
|
165
|
+
"packageFile": "dist/markdown-rules.mjs",
|
|
140
166
|
"bytes": 3255,
|
|
141
167
|
"sha256": "3c2c1660f669eac88fbee4259e83f9227ed651e2e4bb228a861c5a1d8518f6a7"
|
|
142
168
|
},
|
|
143
169
|
{
|
|
144
170
|
"file": "math/integration.mjs",
|
|
145
|
-
"packageFile": "integration.mjs",
|
|
171
|
+
"packageFile": "dist/integration.mjs",
|
|
146
172
|
"bytes": 1493,
|
|
147
173
|
"sha256": "5bd61aa59e78cbab37219b9a569f3b5ad9c5a7723800abc7f3fe7af6b82ae7a6"
|
|
148
174
|
},
|
|
149
175
|
{
|
|
150
176
|
"file": "math/markdown-it.mjs",
|
|
151
|
-
"packageFile": "markdown-it.mjs",
|
|
177
|
+
"packageFile": "dist/markdown-it.mjs",
|
|
152
178
|
"bytes": 2113,
|
|
153
179
|
"sha256": "d57abc5dc3e5a31b6be4507b2f5c57df8431763b8d88feaadbf242cb09af6c9d"
|
|
154
180
|
},
|
|
155
181
|
{
|
|
156
182
|
"file": "math/rehype.mjs",
|
|
157
|
-
"packageFile": "rehype.mjs",
|
|
183
|
+
"packageFile": "dist/rehype.mjs",
|
|
158
184
|
"bytes": 2017,
|
|
159
185
|
"sha256": "7cc9c9d2e7c9b9667368cfc1a5a4f5f86d218b7c8a1acb8d2e12334d41e83bc8"
|
|
160
186
|
},
|
|
161
187
|
{
|
|
162
188
|
"file": "math/stream.mjs",
|
|
163
|
-
"packageFile": "stream.mjs",
|
|
189
|
+
"packageFile": "dist/stream.mjs",
|
|
164
190
|
"bytes": 2530,
|
|
165
191
|
"sha256": "2b26a895e531906be931af6f9f3764297d1ff98bf56875e9df457f82938fc03d"
|
|
166
192
|
},
|
|
167
193
|
{
|
|
168
194
|
"file": "math/index.d.ts",
|
|
169
|
-
"packageFile": "index.d.ts",
|
|
195
|
+
"packageFile": "dist/index.d.ts",
|
|
170
196
|
"bytes": 1698,
|
|
171
197
|
"sha256": "bc14a284cd5caffdf5bfe6825c49c360d313e693bbc0280aa924fd9fc594beb3"
|
|
172
198
|
},
|
|
173
199
|
{
|
|
174
200
|
"file": "math/classic.d.ts",
|
|
175
|
-
"packageFile": "classic.d.ts",
|
|
201
|
+
"packageFile": "dist/classic.d.ts",
|
|
176
202
|
"bytes": 123,
|
|
177
203
|
"sha256": "dfc82014f54ed7364171cb73cc8bc118aba4a5929349f762da82988977f1593d"
|
|
178
204
|
},
|
|
179
205
|
{
|
|
180
206
|
"file": "math/delimiters.d.ts",
|
|
181
|
-
"packageFile": "delimiters.d.ts",
|
|
207
|
+
"packageFile": "dist/delimiters.d.ts",
|
|
182
208
|
"bytes": 479,
|
|
183
209
|
"sha256": "db74cfb4fdd6d87e7f47a5de8ee3a4b78f409a4fe3cd2edeaa8e77660a489617"
|
|
184
210
|
},
|
|
185
211
|
{
|
|
186
212
|
"file": "math/integration.d.ts",
|
|
187
|
-
"packageFile": "integration.d.ts",
|
|
213
|
+
"packageFile": "dist/integration.d.ts",
|
|
188
214
|
"bytes": 370,
|
|
189
215
|
"sha256": "4b3c53b01b34de3b328ef609e65aa3aa530fabc3522238bde335cb8c839cdda3"
|
|
190
216
|
},
|
|
191
217
|
{
|
|
192
218
|
"file": "math/markdown-it.d.ts",
|
|
193
|
-
"packageFile": "markdown-it.d.ts",
|
|
219
|
+
"packageFile": "dist/markdown-it.d.ts",
|
|
194
220
|
"bytes": 383,
|
|
195
221
|
"sha256": "bafce277328ba397bddbbb5101cc2545ba8b8c15830b47f2dc1f05af85de4b1d"
|
|
196
222
|
},
|
|
197
223
|
{
|
|
198
224
|
"file": "math/rehype.d.ts",
|
|
199
|
-
"packageFile": "rehype.d.ts",
|
|
225
|
+
"packageFile": "dist/rehype.d.ts",
|
|
200
226
|
"bytes": 340,
|
|
201
227
|
"sha256": "8f6b230284e64fb483d1ed2c6ed9420958cf1d7e609f71aee62322cabe56339b"
|
|
202
228
|
},
|
|
203
229
|
{
|
|
204
230
|
"file": "math/stream.d.ts",
|
|
205
|
-
"packageFile": "stream.d.ts",
|
|
231
|
+
"packageFile": "dist/stream.d.ts",
|
|
206
232
|
"bytes": 630,
|
|
207
233
|
"sha256": "1b12bc176fdd243db75d247ff4dbb9b4787945167a033154a0d222ad68da4ff0"
|
|
208
234
|
},
|
|
@@ -239,8 +265,8 @@
|
|
|
239
265
|
{
|
|
240
266
|
"file": "math/examples/browser.mjs",
|
|
241
267
|
"packageFile": "examples/browser.mjs",
|
|
242
|
-
"bytes":
|
|
243
|
-
"sha256": "
|
|
268
|
+
"bytes": 945,
|
|
269
|
+
"sha256": "569e66078bce60debc6aeb4d70efa3fdc67eabdf9b349822f1a7117a28311235"
|
|
244
270
|
},
|
|
245
271
|
{
|
|
246
272
|
"file": "math/examples/react.tsx",
|
|
@@ -251,8 +277,8 @@
|
|
|
251
277
|
{
|
|
252
278
|
"file": "math/examples/worker.mjs",
|
|
253
279
|
"packageFile": "examples/worker.mjs",
|
|
254
|
-
"bytes":
|
|
255
|
-
"sha256": "
|
|
280
|
+
"bytes": 370,
|
|
281
|
+
"sha256": "1e9de25f8b636d14d065b0d2b2febbeeed9600fc595a12c09f94ba58f3791de6"
|
|
256
282
|
},
|
|
257
283
|
{
|
|
258
284
|
"file": "math/examples/README.md",
|
package/examples/browser.mjs
CHANGED
package/examples/worker.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
import {render} from '../index.mjs';
|
|
2
|
+
import {render} from '../dist/index.mjs';
|
|
3
3
|
self.onmessage = ({data: {id, source}}) => {
|
|
4
4
|
try { self.postMessage({id, source, result: render(source)}); }
|
|
5
5
|
catch (error) { self.postMessage({id, source, error: {code: error.code, message: error.message}}); }
|