rapier-math 2.6.1 → 3.0.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/CHANGELOG.md +17 -3
- package/LICENSE +1 -1
- package/README.md +20 -31
- package/dist/accessible.d.ts +2 -2
- package/dist/classic.d.ts +1 -1
- package/dist/combined.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/integration.d.ts +1 -1
- package/dist/markdown-it.d.ts +2 -0
- package/dist/rapier-math.js +227 -122
- package/dist/rehype.d.ts +1 -1
- package/docs/api.md +10 -8
- package/docs/font-source.md +30 -19
- package/docs/formula-dark.svg +1 -0
- package/docs/formula-light.svg +1 -0
- package/docs/math-components.json +8 -8
- package/docs/math-resources.json +46 -46
- package/docs/semantics.md +6 -3
- package/package.json +1 -1
- package/src/math/FONT-LICENSE.txt +1 -1
- package/src/math/build-font.py +36 -24
- package/src/math/classic.js +1 -1
- package/src/math/font.js +5 -5
- package/src/math/layout.js +68 -84
- package/src/math/mathml.js +53 -7
- package/src/math/package-readme.mjs +20 -31
- package/src/math/parser.js +102 -25
- package/src/tools/build-math.mjs +11 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 3.0.0 (2026-10-31)
|
|
4
|
+
|
|
5
|
+
- Breaking: types: `renderWithMathML` and `renderAccessible` take no `preview` or `caret`.
|
|
6
|
+
- Types: `markdown-it` takes extra `env` fields; `rehype` works without a `VFile`.
|
|
7
|
+
- Types: the classic `RapierMath` global is a `var`.
|
|
8
|
+
- `node src/tools/build-math.mjs --package .` refreshes source receipts and checksums.
|
|
9
|
+
|
|
10
|
+
## 2.7.0 (2026-10-20)
|
|
11
|
+
|
|
12
|
+
- `\verb` and `\verb*` set verbatim text.
|
|
13
|
+
- `\mathchoice` picks its branch by display or script style, in SVG and MathML.
|
|
14
|
+
- Prescripts render as `mmultiscripts` in MathML.
|
|
15
|
+
- Monospace punctuation, visible space and the sharp s use Latin Modern Mono outlines.
|
|
16
|
+
|
|
17
|
+
## 2.6.1 (2026-10-18)
|
|
4
18
|
|
|
5
19
|
- Use the font's ellipses and correct extensible arrow sizes.
|
|
6
20
|
- Match amscd row spacing and under-accent attachment points.
|
|
7
|
-
- Correct chemistry labels, state spacing and superscripts.
|
|
21
|
+
- Correct chemistry labels, state spacing and superscripts.
|
|
22
|
+
- Keep chemistry arrows at least 2 em wide in MathML.
|
|
8
23
|
- Include the Latin Modern Mono sharp s outline for monospace text.
|
|
9
24
|
- Preserve exact math fence source in shared Markdown rules.
|
|
10
|
-
|
package/LICENSE
CHANGED
|
@@ -32,7 +32,7 @@ Copyright 2003, 2009 B. Jackowski and J. M. Nowacki (on behalf of TeX users grou
|
|
|
32
32
|
Copyright 2003--2009 by B. Jackowski and J.M. Nowacki (on behalf of TeX USERS GROUPS).
|
|
33
33
|
|
|
34
34
|
Rapier math font data, derived from Latin Modern Math 1.959,
|
|
35
|
-
|
|
35
|
+
text outlines from Latin Modern Mono 2.004, and one arrow hook
|
|
36
36
|
from Latin Modern Math Italic 10 Regular 2.003.
|
|
37
37
|
Changes: SVG outline conversion, character and MATH data extraction,
|
|
38
38
|
optical-form closure and lossless path packing.
|
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# Rapier Math
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Use
|
|
3
|
+
TeX to SVG or MathML, synchronously and offline. Latin Modern outlines are embedded in the SVG, so there are no font requests and no runtime downloads. No dependencies.
|
|
6
4
|
|
|
7
5
|
```sh
|
|
8
6
|
npm install rapier-math
|
|
@@ -10,41 +8,32 @@ npm install rapier-math
|
|
|
10
8
|
|
|
11
9
|
```js
|
|
12
10
|
import {renderToString} from 'rapier-math';
|
|
13
|
-
|
|
11
|
+
|
|
12
|
+
const svg = renderToString(String.raw`\frac{-b\pm\sqrt{b^2-4ac}}{2a}`);
|
|
14
13
|
```
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
`globalThis.RapierMath`. The native ESM entry is [dist/index.mjs](dist/index.mjs).
|
|
18
|
-
For one-file copying or inline-script embedding, use the classic file above. The native
|
|
19
|
-
ESM entry imports relative `src/math/` modules: install/serve the whole package or bundle
|
|
20
|
-
that import; copying only `dist/index.mjs` is insufficient. A CDN must retain that graph
|
|
21
|
-
or bundle it. Formula rendering stays synchronous and offline after its chosen script
|
|
22
|
-
or module graph has loaded.
|
|
15
|
+
Try it in [Rapier](https://rapier.website): type \$x^2\$.
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
`rapier-math/combined` for one-parse SVG and MathML, or `rapier-math/accessible` with its stylesheet
|
|
26
|
-
for host composition. All return synchronously. Type declarations accompany the runtime files.
|
|
17
|
+
## Entry points
|
|
27
18
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
19
|
+
| Import | Gives |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `rapier-math` | SVG with the font embedded |
|
|
22
|
+
| `rapier-math/mathml` | Native MathML, no font |
|
|
23
|
+
| `rapier-math/combined` | SVG and MathML from one parse |
|
|
24
|
+
| `rapier-math/accessible` | Accessible output for your own layout, with `rapier-math/accessible.css` |
|
|
25
|
+
| `rapier-math/markdown-it`, `rapier-math/rehype` | Markdown integrations; your parser stays in charge |
|
|
26
|
+
| `rapier-math/stream` | Formulas in streamed text, such as model output |
|
|
27
|
+
| `rapier-math/classic` | [dist/rapier-math.js](dist/rapier-math.js): one file, `globalThis.RapierMath` |
|
|
33
28
|
|
|
34
|
-
|
|
29
|
+
Types ship with every entry. The classic file is the one to copy or inline: 742,684 bytes, 421,701 gzipped, font included. The ES modules import `src/math/`, so serve or bundle the whole package rather than copying `dist/index.mjs` alone.
|
|
35
30
|
|
|
36
|
-
|
|
37
|
-
modules in `src/math/` directly, sharing one parser without a duplicate generated renderer. Build
|
|
38
|
-
tools live in `src/tools/`. Optional adapters have one source copy in `dist/`. Examples and documentation each
|
|
39
|
-
have their own directory. Only the current release is kept in this checkout.
|
|
31
|
+
[API](docs/api.md) · [MathML and accessibility](docs/semantics.md) · [Examples](examples/README.md) · [Font](docs/font-source.md) · [Changes](CHANGELOG.md)
|
|
40
32
|
|
|
41
|
-
|
|
33
|
+
## Build
|
|
42
34
|
|
|
43
|
-
|
|
35
|
+
`node src/tools/build-math.mjs --package .` regenerates `dist/` from `src/math/`.
|
|
44
36
|
|
|
45
|
-
|
|
46
|
-
licensed under the GUST Font License. [LICENSE](LICENSE) contains both complete grants.
|
|
47
|
-
[Component provenance](docs/math-components.json) and [source hashes](docs/math-resources.json)
|
|
48
|
-
travel with the package.
|
|
37
|
+
## License
|
|
49
38
|
|
|
50
|
-
|
|
39
|
+
Code: MIT. Embedded Latin Modern outlines and metrics: GUST Font License. Both are in [LICENSE](LICENSE). [Components](docs/math-components.json) and [source hashes](docs/math-resources.json) ship with the package.
|
package/dist/accessible.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export interface AccessibleResult extends SemanticRenderResult {
|
|
|
6
6
|
/** Authored links use visible native MathML, with standalone SVG still returned. */
|
|
7
7
|
presentation: 'svg-mathml' | 'mathml' | 'refused';
|
|
8
8
|
}
|
|
9
|
-
/** Include accessible.css when inserting the
|
|
10
|
-
export function renderAccessible(source: unknown, options?: RenderOptions): AccessibleResult;
|
|
9
|
+
/** Include accessible.css when inserting the composition. Incomplete source is not repaired. */
|
|
10
|
+
export function renderAccessible(source: unknown, options?: Omit<RenderOptions, 'preview' | 'caret'>): AccessibleResult;
|
package/dist/classic.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type RapierMath from './index.js';
|
|
|
3
3
|
import type {toMathML} from './mathml.js';
|
|
4
4
|
import type {renderWithMathML} from './combined.js';
|
|
5
5
|
declare global {
|
|
6
|
-
|
|
6
|
+
var RapierMath: typeof import('./index.js').default & Readonly<{
|
|
7
7
|
toMathML: typeof toMathML; renderWithMathML: typeof renderWithMathML;
|
|
8
8
|
}>;
|
|
9
9
|
}
|
package/dist/combined.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
import type {RenderOptions, SemanticRenderResult} from './index.js';
|
|
3
|
-
/** Render SVG and MathML from one
|
|
4
|
-
export function renderWithMathML(source: unknown, options?: RenderOptions): SemanticRenderResult;
|
|
3
|
+
/** Render SVG and MathML from one strict parse; incomplete source is not repaired. */
|
|
4
|
+
export function renderWithMathML(source: unknown, options?: Omit<RenderOptions, 'preview' | 'caret'>): SemanticRenderResult;
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
import {parseMathTex as parse} from '../src/math/parser.js';
|
|
3
3
|
import {renderMath as render, mathRenderToString as renderToString} from '../src/math/api.js';
|
|
4
4
|
import {mathFit as fit, mathObserve as observe} from '../src/math/browser.js';
|
|
5
|
-
const version = "
|
|
5
|
+
const version = "3.0.0";
|
|
6
6
|
export {version, parse, render, renderToString, fit, observe};
|
|
7
7
|
export default Object.freeze({version, parse, render, renderToString, fit, observe});
|
package/dist/integration.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {MathSession} from './stream.js';
|
|
|
4
4
|
export interface IntegrationOptions {
|
|
5
5
|
/** Insert SVG with assistive MathML. Include accessible.css. */
|
|
6
6
|
accessible?: boolean;
|
|
7
|
-
/** With
|
|
7
|
+
/** With a session, plain-data options are captured once per render. preview/caret apply only without accessible output. */
|
|
8
8
|
renderOptions?: RenderOptions;
|
|
9
9
|
/** Per document. Default 1024. Exhaustion leaves subsequent math as source. */
|
|
10
10
|
maxFormulas?: number;
|
package/dist/markdown-it.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type {MathError} from './index.js';
|
|
|
6
6
|
import type {MathSession} from './stream.js';
|
|
7
7
|
export interface MarkdownMathOptions extends DelimiterOptions, IntegrationOptions {}
|
|
8
8
|
export interface MarkdownMathEnv {
|
|
9
|
+
/** The Markdown host and its other plug-ins may carry additional document data. */
|
|
10
|
+
[key: string | symbol]: unknown;
|
|
9
11
|
/** Optional formula reuse for one message; each render still owns fresh budgets. */
|
|
10
12
|
rapierMathSession?: MathSession;
|
|
11
13
|
rapierMathErrors?: {source: string; errors: MathError[]}[];
|