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 CHANGED
@@ -1,10 +1,24 @@
1
1
  # Changelog
2
2
 
3
- ## 2.6.1
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. Keep chemistry arrows at least 2 em wide in MathML.
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
- the sharp s of Latin Modern Mono 2.004, and one arrow hook
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
- Offline TeX formulas as SVG or structured MathML. Embedded Latin Modern outlines for SVG; font-free native MathML. Synchronous, with no runtime downloads.
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
- const svg = renderToString(String.raw`\frac{a}{b}`);
11
+
12
+ const svg = renderToString(String.raw`\frac{-b\pm\sqrt{b^2-4ac}}{2a}`);
14
13
  ```
15
14
 
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
- 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
- The SVG entry and classic script include the font. Use `rapier-math/mathml` for font-free MathML,
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
- - [API and integration guide](docs/api.md)
29
- - [MathML, accessibility and source contracts](docs/semantics.md)
30
- - [Runnable examples](examples/README.md)
31
- - [Font source and regeneration](docs/font-source.md)
32
- - [Changes](CHANGELOG.md)
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
- ## Develop
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
- The classic script and native entry points live in `dist/`. Native entries import the editable
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
- Run `node src/tools/build-math.mjs --package .` to regenerate the classic and ESM files from source.
33
+ ## Build
42
34
 
43
- ## License
35
+ `node src/tools/build-math.mjs --package .` regenerates `dist/` from `src/math/`.
44
36
 
45
- The renderer and adapters are MIT-licensed. Embedded Latin Modern outlines and metrics are
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
- Version 2.6.1. Classic payload: 733943 bytes; gzip (level 9): 418021 bytes.
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.
@@ -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 combined SVG/MathML composition. */
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
- const RapierMath: typeof import('./index.js').default & Readonly<{
6
+ var RapierMath: typeof import('./index.js').default & Readonly<{
7
7
  toMathML: typeof toMathML; renderWithMathML: typeof renderWithMathML;
8
8
  }>;
9
9
  }
@@ -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 admitted parse; check each result independently. */
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 = "2.6.1";
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});
@@ -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 an explicit session, plain-data options and screen are captured once per document render. */
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;
@@ -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[]}[];