rapier-math 2.1.0 → 2.3.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 +1 -1
- package/dist/index.mjs +1 -1
- package/dist/rapier-math.js +397 -128
- package/docs/api.md +4 -2
- package/docs/font-source.md +17 -11
- package/docs/math-components.json +6 -6
- package/docs/math-resources.json +31 -31
- package/docs/semantics.md +1 -1
- package/package.json +1 -1
- package/src/math/browser.js +28 -17
- package/src/math/build-font.py +153 -226
- package/src/math/classic.js +1 -1
- package/src/math/font.js +66 -33
- package/src/math/layout.js +76 -30
- package/src/math/mathml.js +10 -6
- package/src/math/parser.js +191 -26
- package/src/math/responsive.js +7 -5
- package/src/math/symbols.js +18 -10
- package/src/tools/build-math.mjs +4 -5
package/docs/api.md
CHANGED
|
@@ -287,7 +287,7 @@ evaluation; adding a raw TeX label does not satisfy that requirement.
|
|
|
287
287
|
|
|
288
288
|
## Security and deployment
|
|
289
289
|
|
|
290
|
-
The renderer emits local SVG outlines, never executable HTML, remote font/image fetches or loaded TeX
|
|
290
|
+
The renderer emits local SVG outlines (and plain `text` runs for characters outside the font), never executable HTML, remote font/image fetches or loaded TeX
|
|
291
291
|
extensions. Authored links permit only HTTP(S) and use `noopener noreferrer`. Insert only the returned
|
|
292
292
|
SVG, never concatenate TeX or arbitrary HTML into the sink. On failure, use a text node or the framework's
|
|
293
293
|
escaped text rendering. Formula safety does not sanitize surrounding Markdown.
|
|
@@ -311,7 +311,9 @@ Greek and mathematical alphabets, text/color/size/spacing, local macros, and sel
|
|
|
311
311
|
Existing supported package names select built-in syntax; there is no external package/file loader.
|
|
312
312
|
This is not a complete TeX document engine. No automatic numbering or cross-formula reference guarantee.
|
|
313
313
|
Unsupported commands give diagnostics. Lowercase script/bold-script requests use ordinary-letter fallbacks
|
|
314
|
-
where Latin Modern lacks those alphabets. All embedded licensed outlines remain present.
|
|
314
|
+
where Latin Modern lacks those alphabets. All embedded licensed outlines remain present. Letters, digits
|
|
315
|
+
and symbols the font lacks (for example CJK, Cyrillic, Arabic or emoji) are drawn as an SVG `text` run in
|
|
316
|
+
the reader's own serif font, fitted to an estimated width, rather than refused.
|
|
315
317
|
|
|
316
318
|
## Package and proof
|
|
317
319
|
|
package/docs/font-source.md
CHANGED
|
@@ -101,14 +101,20 @@ coordinates if present. Missing italic corrections are zero; missing accent atta
|
|
|
101
101
|
Assembly parts retain the OpenType order: bottom to top vertically, left to right horizontally. Latin Modern has
|
|
102
102
|
no MATH Device adjustments. Hint programs and general text shaping tables are not used by the SVG renderer.
|
|
103
103
|
|
|
104
|
-
Contour profiles cover 1,
|
|
105
|
-
dotless forms. Entry `i + 1` bounds the original contour within `[y0 + i * edgeStep, y0 + (i + 1) * edgeStep]`;
|
|
104
|
+
Contour profiles cover 1,190 ASCII alphanumeric, mathematical italic and script glyphs, with U+210E (the
|
|
105
|
+
italic h) and the optical and dotless forms. Entry `i + 1` bounds the original contour within `[y0 + i * edgeStep, y0 + (i + 1) * edgeStep]`;
|
|
106
106
|
`null` means no ink. Cubic intersections and horizontal extrema determine the bounds. Values round outward
|
|
107
107
|
with a small numerical guard. Profiles are derived spacing data; they do not replace outlines or pretend to be
|
|
108
108
|
an original MATH kern table. Layout compares intersecting strips from both glyphs when placing scripts.
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
The asset stores neither bounds nor profiles. The decoder derives both from the outline: bounds with the
|
|
111
|
+
arithmetic of fontTools' `BoundsPen`, profiles with the strip algorithm above, operation for operation in
|
|
112
|
+
IEEE double precision. For this font every derived bound and profile equals the value the 2.2.0 asset stored
|
|
113
|
+
(2.2.0 had no profile for U+210E and its two optical forms).
|
|
114
|
+
|
|
115
|
+
Character mappings, optical substitutions, stretch constructions, the profiled glyph set and record offsets
|
|
116
|
+
occupy a compact index decoded at module load. Glyph metrics and outlines stay in independent raw DEFLATE pages
|
|
117
|
+
until requested. Every page
|
|
112
118
|
ends at a record boundary and contains at most 16,384 decoded bytes. The complete set of pages travels in the
|
|
113
119
|
same asset; rare characters, stretch parts and optical forms require no additional download.
|
|
114
120
|
|
|
@@ -118,19 +124,19 @@ exact differences from an earlier contour with the same structure. Parent chains
|
|
|
118
124
|
The generator prefers small coordinate differences as well as short records, because the smallest initial
|
|
119
125
|
record does not necessarily produce the smallest compressed page. Glyph assembly restores the original
|
|
120
126
|
absolute `M/L/H/V/C/Z` paths, including contour order; existing outline-part consumers use those commands.
|
|
127
|
+
A contour whose closing curve ends at its start omits that end point; the decoder returns the curve to the start.
|
|
121
128
|
|
|
122
|
-
Glyph metrics use reversible
|
|
123
|
-
They retain the complete original
|
|
129
|
+
Glyph metrics use a reversible half-advance accent predictor with a median origin per metric field.
|
|
130
|
+
They retain the complete original advance, italic and accent measurements. Signed record integers
|
|
124
131
|
use zigzag values: values below 240 take one byte, the next 3,840 values take two bytes, and larger values use
|
|
125
132
|
an escape followed by unsigned LEB128. The coordinate unit is exact; this encoding performs no quantization.
|
|
126
133
|
|
|
127
|
-
Profiles retain the original left/right strip coordinates and exact differences from matching strip structures.
|
|
128
|
-
Identical arrays share storage: all 1,187 glyph-to-profile mappings are represented by 1,080 unique records.
|
|
129
134
|
The renderer only asks for profiles when side-script placement can use them.
|
|
130
135
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
cached glyphs
|
|
136
|
+
Each inflated page, completed glyph record and contour profile stays for the life of the module, so the font
|
|
137
|
+
itself bounds these caches: the pages inflate to about 520 KB. Temporary parent coordinates and page views are
|
|
138
|
+
discarded after a glyph is assembled; cached glyphs keep the completed path and metrics, and profiled glyphs
|
|
139
|
+
also keep the outline segments their profile is derived from.
|
|
134
140
|
These caches contain font data only. They retain no formula source, parse tree, layout result, SVG element or
|
|
135
141
|
document. Returned internal records are read-only to consumers.
|
|
136
142
|
|
|
@@ -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-2.
|
|
6
|
-
"documentNamespace": "https://rapier.website/spdx/rapier-math-2.
|
|
5
|
+
"name": "rapier-math-2.3.0",
|
|
6
|
+
"documentNamespace": "https://rapier.website/spdx/rapier-math-2.3.0-f5df4637eb2c6fffe325f1f6e9c12132aa4f7741abd24c789fc7ac30c8cf499f",
|
|
7
7
|
"creationInfo": {
|
|
8
|
-
"created": "2026-10-
|
|
8
|
+
"created": "2026-10-15T04:22:09.842Z",
|
|
9
9
|
"creators": [
|
|
10
10
|
"Tool: rapier-math-components",
|
|
11
11
|
"Organization: rapier.website"
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
{
|
|
16
16
|
"name": "rapier-math",
|
|
17
17
|
"SPDXID": "SPDXRef-rapier-math",
|
|
18
|
-
"versionInfo": "2.
|
|
18
|
+
"versionInfo": "2.3.0",
|
|
19
19
|
"downloadLocation": "NOASSERTION",
|
|
20
20
|
"filesAnalyzed": false,
|
|
21
21
|
"licenseConcluded": "MIT AND LicenseRef-GUST-Font-License",
|
|
22
22
|
"licenseDeclared": "MIT AND LicenseRef-GUST-Font-License",
|
|
23
23
|
"copyrightText": "NOASSERTION",
|
|
24
|
-
"sourceInfo": "Verified current build inputs: math-resources.json (SHA-256
|
|
24
|
+
"sourceInfo": "Verified current build inputs: math-resources.json (SHA-256 43190d50be5b14a16f69f889041617766b62eab41b88be177aa3e2b388dc1f94).",
|
|
25
25
|
"checksums": [
|
|
26
26
|
{
|
|
27
27
|
"algorithm": "SHA256",
|
|
28
|
-
"checksumValue": "
|
|
28
|
+
"checksumValue": "f5df4637eb2c6fffe325f1f6e9c12132aa4f7741abd24c789fc7ac30c8cf499f"
|
|
29
29
|
}
|
|
30
30
|
]
|
|
31
31
|
},
|
package/docs/math-resources.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundle": "rapier-math-2.
|
|
2
|
+
"bundle": "rapier-math-2.3.0.js",
|
|
3
3
|
"packageBundle": "dist/rapier-math.js",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
5
5
|
"license": "MIT AND LicenseRef-GUST-Font-License",
|
|
6
|
-
"bytes":
|
|
7
|
-
"gzipBytes":
|
|
8
|
-
"sha256": "
|
|
9
|
-
"sha384": "
|
|
6
|
+
"bytes": 673393,
|
|
7
|
+
"gzipBytes": 399554,
|
|
8
|
+
"sha256": "f5df4637eb2c6fffe325f1f6e9c12132aa4f7741abd24c789fc7ac30c8cf499f",
|
|
9
|
+
"sha384": "ie925auPTOH6Zh27w4EowUzc61aeLAYB+3hxZS59bBrEZ21joUXxNWEPR+GBvVn1",
|
|
10
10
|
"sources": [
|
|
11
11
|
{
|
|
12
12
|
"file": "math/font.js",
|
|
13
13
|
"packageFile": "src/math/font.js",
|
|
14
|
-
"bytes":
|
|
15
|
-
"sha256": "
|
|
14
|
+
"bytes": 465845,
|
|
15
|
+
"sha256": "d10ac2bcef6e624c4b052602efbbd70c8c69bd40b7e2c5096526291fcae4f60b"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"file": "math/symbols.js",
|
|
19
19
|
"packageFile": "src/math/symbols.js",
|
|
20
|
-
"bytes":
|
|
21
|
-
"sha256": "
|
|
20
|
+
"bytes": 9305,
|
|
21
|
+
"sha256": "b48853a637d57697b58dfec4f728e9d67ca9fa041b5a0ccdb4d513d0dc4b4137"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"file": "math/parser.js",
|
|
25
25
|
"packageFile": "src/math/parser.js",
|
|
26
|
-
"bytes":
|
|
27
|
-
"sha256": "
|
|
26
|
+
"bytes": 84418,
|
|
27
|
+
"sha256": "3b7ccf2c7f32fba45a70408939e4c7d5bf18ee5ee9f3f3109b101e81985d5050"
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
"file": "math/source.js",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
{
|
|
42
42
|
"file": "math/layout.js",
|
|
43
43
|
"packageFile": "src/math/layout.js",
|
|
44
|
-
"bytes":
|
|
45
|
-
"sha256": "
|
|
44
|
+
"bytes": 40185,
|
|
45
|
+
"sha256": "c1425c843f3684e24a530a0bdfbeec65626cd6c41893abc395cc5766e38815c0"
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"file": "math/fallbacks.js",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
{
|
|
54
54
|
"file": "math/responsive.js",
|
|
55
55
|
"packageFile": "src/math/responsive.js",
|
|
56
|
-
"bytes":
|
|
57
|
-
"sha256": "
|
|
56
|
+
"bytes": 14156,
|
|
57
|
+
"sha256": "ee1bc05c23be50380c59eed5f9a51057464991695c030563fca8d64d2230d3ec"
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"file": "math/api.js",
|
|
@@ -65,14 +65,14 @@
|
|
|
65
65
|
{
|
|
66
66
|
"file": "math/browser.js",
|
|
67
67
|
"packageFile": "src/math/browser.js",
|
|
68
|
-
"bytes":
|
|
69
|
-
"sha256": "
|
|
68
|
+
"bytes": 10946,
|
|
69
|
+
"sha256": "3c163cbe795a6be2781295b10fc41bd8e94248c3bbee521abff43d03fbefbc5d"
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
"file": "math/mathml.js",
|
|
73
73
|
"packageFile": "src/math/mathml.js",
|
|
74
|
-
"bytes":
|
|
75
|
-
"sha256": "
|
|
74
|
+
"bytes": 29496,
|
|
75
|
+
"sha256": "f91054b5cabbb32bce79eea6d60f91a3a513a1613ef587d08a86086a983859a5"
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
"file": "math/semantic-api.js",
|
|
@@ -90,21 +90,21 @@
|
|
|
90
90
|
"file": "math/classic.js",
|
|
91
91
|
"packageFile": "src/math/classic.js",
|
|
92
92
|
"bytes": 269,
|
|
93
|
-
"sha256": "
|
|
93
|
+
"sha256": "e42b812cf9772909c9178b15a85ac300c5e35ae6f56d66261f24654916442c74"
|
|
94
94
|
}
|
|
95
95
|
],
|
|
96
96
|
"recipe": [
|
|
97
97
|
{
|
|
98
98
|
"file": "math/build-font.py",
|
|
99
99
|
"packageFile": "src/math/build-font.py",
|
|
100
|
-
"bytes":
|
|
101
|
-
"sha256": "
|
|
100
|
+
"bytes": 32576,
|
|
101
|
+
"sha256": "98599660cf23e0ee5e38d35732ff353f634c2d4ce641072b0834089533d94836"
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
"file": "math/FONT-SOURCE.md",
|
|
105
105
|
"packageFile": "docs/font-source.md",
|
|
106
|
-
"bytes":
|
|
107
|
-
"sha256": "
|
|
106
|
+
"bytes": 10739,
|
|
107
|
+
"sha256": "621db58ca1b5fcacb450e8f74dfabc533d6856544cf2abb6333a637636d1e0c9"
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
"file": "math/FONT-LICENSE.txt",
|
|
@@ -121,8 +121,8 @@
|
|
|
121
121
|
{
|
|
122
122
|
"file": "tools/build-math.mjs",
|
|
123
123
|
"packageFile": "src/tools/build-math.mjs",
|
|
124
|
-
"bytes":
|
|
125
|
-
"sha256": "
|
|
124
|
+
"bytes": 9577,
|
|
125
|
+
"sha256": "442a21aa7c113f93aa706d52a352cb54cbbf2dac33e68e54bd47dafa6f2830e0"
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
"file": "math/LICENSE-MIT",
|
|
@@ -163,14 +163,14 @@
|
|
|
163
163
|
{
|
|
164
164
|
"file": "math/README.md",
|
|
165
165
|
"packageFile": "docs/api.md",
|
|
166
|
-
"bytes":
|
|
167
|
-
"sha256": "
|
|
166
|
+
"bytes": 23366,
|
|
167
|
+
"sha256": "d3d7d20900f5d32f89182bc8fead8ef08cb57f1173a0306dfb98fe60afc0fa73"
|
|
168
168
|
},
|
|
169
169
|
{
|
|
170
170
|
"file": "math/SEMANTICS.md",
|
|
171
171
|
"packageFile": "docs/semantics.md",
|
|
172
|
-
"bytes":
|
|
173
|
-
"sha256": "
|
|
172
|
+
"bytes": 18282,
|
|
173
|
+
"sha256": "98984313665984aaa29fd816cc7b79691deac7450d5d76b8e7dc0f79b575e2cf"
|
|
174
174
|
},
|
|
175
175
|
{
|
|
176
176
|
"file": "math/semantic-verify.mjs",
|
package/docs/semantics.md
CHANGED
|
@@ -53,7 +53,7 @@ is the portable structural target. Extensions and lossy cases are reported expli
|
|
|
53
53
|
| TeX/AST family | Mapping and qualification |
|
|
54
54
|
| --- | --- |
|
|
55
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`;
|
|
56
|
+
| Identifiers and alphabets | `mi`; a single default or italic letter stays plain, so MathML Core italicizes it and assistive technology reads the ordinary letter. Other alphabets reuse the SVG renderer's pure Unicode mapping. Roman identifiers use `mathvariant="normal"`. Text spaces become no-break spaces because MathML trims token whitespace. |
|
|
57
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
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
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. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapier-math",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Self-contained offline LaTeX-to-SVG rendering with Latin Modern outlines, optional Markdown integrations and streaming helpers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
package/src/math/browser.js
CHANGED
|
@@ -42,9 +42,10 @@ function mathSnapRule(original, matrix, ratio) {
|
|
|
42
42
|
'v' + mathNumber(height) + 'h' + mathNumber(-width) + 'Z'};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
// Every rule is measured before any is rewritten, so the browser lays the page out once, not once per formula.
|
|
46
|
+
function mathSnapRules(svgs) {
|
|
47
|
+
const measured=[];
|
|
48
|
+
for(const svg of svgs)for(const rule of svg.querySelectorAll('[data-math-rule],[data-math-line]')) {
|
|
48
49
|
let original=mathRuleOriginals.get(rule);
|
|
49
50
|
if(!original) {
|
|
50
51
|
const box=rule.getBBox(), axis=rule.getAttribute('data-math-line'), thickness=Number(rule.getAttribute('stroke-width'));
|
|
@@ -53,7 +54,10 @@ function mathSnapRules(svg) {
|
|
|
53
54
|
if(axis==='vertical') {original.x-=thickness/2;original.width=thickness;}
|
|
54
55
|
mathRuleOriginals.set(rule,original);
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
measured.push([rule,original,rule.getScreenCTM(),svg.ownerDocument.defaultView.devicePixelRatio || 1]);
|
|
58
|
+
}
|
|
59
|
+
for(const [rule,original,matrix,ratio] of measured) {
|
|
60
|
+
const snapped=mathSnapRule(original,matrix,ratio);
|
|
57
61
|
if(!snapped)continue;
|
|
58
62
|
let path=snapped.d;
|
|
59
63
|
if(original.axis==='horizontal') {
|
|
@@ -69,13 +73,18 @@ function mathSnapRules(svg) {
|
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
// Reads only: the column, font and paper of one formula.
|
|
77
|
+
function mathFitMeasure(svg, printing) {
|
|
73
78
|
if(!svg.isConnected)return null;
|
|
74
|
-
const
|
|
79
|
+
const view=svg.ownerDocument.defaultView,column=mathColumn(svg),style=view.getComputedStyle(column),font=parseFloat(view.getComputedStyle(svg).fontSize);
|
|
75
80
|
const available=column.clientWidth-(parseFloat(style.paddingLeft) || 0)-(parseFloat(style.paddingRight) || 0);
|
|
76
|
-
if(!(available>0 && font>0))return column;
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
if(!(available>0 && font>0))return {column};
|
|
82
|
+
return {svg,column,font,width:Math.max(.1,(available-.25)/font),dark:!printing && mathDarkPaper(svg),ratio:view.devicePixelRatio || 1};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Writes only: re-render and restyle one measured formula.
|
|
86
|
+
function mathFitApply({svg,font,width,dark,ratio}, printing) {
|
|
87
|
+
const doc=svg.ownerDocument,view=doc.defaultView,source=svg.getAttribute('aria-label'),display=svg.getAttribute('data-rapier-math')==='display';
|
|
79
88
|
const screen=printing?undefined:{fontSize:font/mathFontRatio,pixelRatio:ratio,dark};
|
|
80
89
|
const screenKey=printing?'':mathNumber(font)+'|'+mathNumber(ratio)+'|'+dark;
|
|
81
90
|
let state=mathBrowserStates.get(svg);
|
|
@@ -112,13 +121,19 @@ function mathFitElement(svg, printing = false) {
|
|
|
112
121
|
node.setAttribute('fill-opacity','1');node.setAttribute('stroke-opacity','1');
|
|
113
122
|
}
|
|
114
123
|
}
|
|
115
|
-
|
|
116
|
-
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// All formulas are measured, then all rewritten, then all rules snapped: three layouts for any number of formulas.
|
|
127
|
+
function mathFitElements(svgs, printing) {
|
|
128
|
+
const measured=svgs.map(svg=>mathFitMeasure(svg,printing)).filter(Boolean),fitted=measured.filter(item=>item.svg);
|
|
129
|
+
for(const item of fitted)mathFitApply(item,printing);
|
|
130
|
+
if(!printing)mathSnapRules(fitted.map(item=>item.svg));
|
|
131
|
+
return measured.map(item=>item.column);
|
|
117
132
|
}
|
|
118
133
|
|
|
119
134
|
function mathFit(root) {
|
|
120
135
|
const nodes=mathElements(root);
|
|
121
|
-
|
|
136
|
+
if(nodes.length)mathFitElements(nodes,nodes[0].ownerDocument.defaultView.matchMedia('print').matches);
|
|
122
137
|
return nodes.length;
|
|
123
138
|
}
|
|
124
139
|
|
|
@@ -129,11 +144,7 @@ function mathObserveDocument(doc) {
|
|
|
129
144
|
if(!active)return;
|
|
130
145
|
if(frame!==null)view.cancelAnimationFrame(frame);
|
|
131
146
|
frame=null;
|
|
132
|
-
const wanted=new Set();
|
|
133
|
-
for(const svg of nodes.keys()) {
|
|
134
|
-
if(!svg.isConnected || svg.ownerDocument!==doc || !svg.matches(mathSvgSelector))continue;
|
|
135
|
-
const column=mathFitElement(svg,printing);if(column)wanted.add(column);
|
|
136
|
-
}
|
|
147
|
+
const wanted=new Set(mathFitElements([...nodes.keys()].filter(svg=>svg.isConnected && svg.ownerDocument===doc && svg.matches(mathSvgSelector)),printing));
|
|
137
148
|
for(const column of columns)if(!wanted.has(column)) {resize.unobserve(column);columns.delete(column);}
|
|
138
149
|
for(const column of wanted)if(!columns.has(column)) {resize.observe(column);columns.add(column);}
|
|
139
150
|
};
|