@uniweb/kit 0.10.23 → 0.11.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/package.json +4 -3
- package/src/math-tokens.css +97 -69
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Standard component library for Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -43,9 +43,10 @@
|
|
|
43
43
|
"fuse.js": "^7.0.0",
|
|
44
44
|
"shiki": "^3.0.0",
|
|
45
45
|
"tailwind-merge": "^3.6.0",
|
|
46
|
+
"temml": "^0.13.2",
|
|
46
47
|
"@uniweb/scene": "0.1.3",
|
|
47
|
-
"@uniweb/
|
|
48
|
-
"@uniweb/
|
|
48
|
+
"@uniweb/core": "0.8.2",
|
|
49
|
+
"@uniweb/semantic-parser": "1.2.1"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"react": "^19.0.0",
|
package/src/math-tokens.css
CHANGED
|
@@ -5,85 +5,113 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @import "@uniweb/kit/math-tokens.css";
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
8
|
+
* That single import is the whole contract: it pulls Temml's own stylesheet AND
|
|
9
|
+
* the two corrections below. `prose-tokens.css` does NOT pull it in — a
|
|
10
|
+
* foundation that renders equations imports both, and prose-tokens' own header
|
|
11
|
+
* says so. (`framework/_contracts/math-css-parity.test.js` fails if any kit
|
|
12
|
+
* stylesheet imports a sibling.) Rendering math and setting up prose typography
|
|
13
|
+
* are different decisions: the academic template has 23 equations and no prose
|
|
14
|
+
* column, and while these rules lived inside prose-tokens it shipped its maths
|
|
15
|
+
* unstyled. Correct metrics are not a typography opt-in.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* ── Why the @import, and why it is not a copy ──
|
|
18
|
+
*
|
|
19
|
+
* Temml renders LaTeX to MathML and expects its own stylesheet to be present.
|
|
20
|
+
* That sheet is not decoration: `<menclose>` is NOT a MathML-Core element, it is
|
|
21
|
+
* Temml's polyfill, and the rules that draw `\cancel`, `\overline` and `\sout`
|
|
22
|
+
* over it live only there. Without them those constructs render as the bare
|
|
23
|
+
* term — a formula that means something different from what the author wrote.
|
|
24
|
+
* It also carries the `@font-face` for `Temml.woff2` and the per-engine
|
|
25
|
+
* `@supports` arms for accents and stretchy glyphs.
|
|
26
|
+
*
|
|
27
|
+
* The font is load-bearing for more ordinary content than it looks. Two rules
|
|
28
|
+
* ask for it: `math .mathscr` (`\mathscr`, a clone of KaTeX_Script remapped onto
|
|
29
|
+
* Unicode 1D49C–1D4B5) and `mo.tml-prime` — so every `f'` and `f''` depends on
|
|
30
|
+
* it for vertical alignment. Note it is NOT what renders `\mathcal`: that goes
|
|
31
|
+
* through `*.mathcal { font-feature-settings: 'ss01' }`, a NotoSans stylistic
|
|
32
|
+
* set, and is unaffected by the font's presence.
|
|
33
|
+
*
|
|
34
|
+
* ⚠️ Do not read that `@font-face` as "math fonts are handled" — it is 9 KB of
|
|
35
|
+
* script capitals and primes, not a math font. The actual glyphs, stretchy
|
|
36
|
+
* brackets and radicals come from an OpenType MATH font on the READER's machine:
|
|
37
|
+
* Temml's stack ends in the generic `math` keyword, which is the CSS mechanism
|
|
38
|
+
* for "give me whatever math font you have". We ship none, deliberately — STIX
|
|
39
|
+
* Two Math is ~820 KB, which is a lot to put in every math-bearing foundation.
|
|
40
|
+
*
|
|
41
|
+
* As of 2026-08-08 that is fine on desktop (Windows ships Cambria Math, macOS
|
|
42
|
+
* ships STIXTwoMath.otf in /System/Library/Fonts/Supplemental) and is the weak
|
|
43
|
+
* spot on Linux and Android, which often have neither. To test any machine:
|
|
44
|
+
* render a `pmatrix` and see whether its parentheses stretch to the rows. If
|
|
45
|
+
* this ever needs solving, the missing lever is a `math` font role in
|
|
46
|
+
* `theme.yml` — the roles today are body / heading / code.
|
|
47
|
+
*
|
|
48
|
+
* It is imported rather than vendored because the bundler resolves the font URL
|
|
49
|
+
* for us — Vite emits `Temml.woff2` as an asset and rewrites the `src`. A text
|
|
50
|
+
* copy breaks that, and drifts from the Temml that produced the markup.
|
|
51
|
+
*
|
|
52
|
+
* ⚠️ `temml` is therefore a DIRECT dependency of kit, for the same reason
|
|
53
|
+
* `shiki` and `fuse.js` are: kit is bundled into a foundation by that
|
|
54
|
+
* foundation's Vite build, so kit's own imports must resolve from the
|
|
55
|
+
* foundation's `node_modules`. Only this stylesheet and the font reach a bundle;
|
|
56
|
+
* kit never imports Temml's JS.
|
|
57
|
+
*
|
|
58
|
+
* ── Why only two rules below ──
|
|
59
|
+
*
|
|
60
|
+
* This file used to carry eight, and six of them were Temml's own restated —
|
|
61
|
+
* lifted individually, without the sheet that scopes them, which is what caused
|
|
62
|
+
* the gap this import closes. Restating them was worse than redundant:
|
|
63
|
+
*
|
|
64
|
+
* .tml-right / .tml-left Temml declares these TWICE — plain, then
|
|
65
|
+
* `text-align: -webkit-right` inside a Chromium
|
|
66
|
+
* `@supports` arm. An unconditional copy landing
|
|
67
|
+
* last defeated the arm in the browser it was for.
|
|
68
|
+
* .tml-sml-pad Temml scopes it to non-Firefox; ours did not.
|
|
69
|
+
* mtable.tml-jot mtd Temml has it, same values, plus a Firefox variant.
|
|
70
|
+
* .tml-eqn::before Temml has it, and `body { counter-reset }` too.
|
|
71
|
+
*
|
|
72
|
+
* Anything Temml already states correctly is now simply Temml's. What is left is
|
|
73
|
+
* what Temml genuinely does not have.
|
|
19
74
|
*/
|
|
75
|
+
@import "temml/dist/Temml-Local.css";
|
|
20
76
|
|
|
21
|
-
/* ───
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
and `tml-right` carry the `&` column alignment of an `aligned` environment,
|
|
27
|
-
`tml-jot` its extra row spacing. Undefined, a derivation's `=` signs drift
|
|
28
|
-
out of line and its rows sit flush. Those three declarations are Temml's own.
|
|
29
|
-
|
|
30
|
-
The `math mtd` rule is not. Temml's stylesheet only *adjusts* row spacing for
|
|
31
|
-
jot, on the stated assumption that mtd already gets 0.5ex of vertical padding
|
|
32
|
-
"per MathML-Core and user-agent CSS" — but a pristine mtd measures 0px in
|
|
33
|
-
Chrome (2026-07). A pmatrix or cases carries no tml-* class at all, so
|
|
34
|
-
Temml's stylesheet alone fixes the derivation and leaves the matrix touching.
|
|
35
|
-
|
|
36
|
-
These live here rather than in their own opt-in file because correct math
|
|
37
|
-
metrics are not a design choice the way callout colours are — a site that
|
|
38
|
-
sets its typography should not also have to know this.
|
|
39
|
-
|
|
40
|
-
press ships the same declarations to the EPUB and Paged.js lanes, which have
|
|
41
|
-
their own stylesheets and cannot import this one. That duplicate is pinned by
|
|
42
|
-
`framework/_contracts/math-css-parity.test.js`, not by trust. */
|
|
43
|
-
.tml-right { text-align: right; }
|
|
44
|
-
.tml-left { text-align: left; }
|
|
45
|
-
.tml-sml-pad { padding-left: 0.05em; }
|
|
46
|
-
math mtd { padding-top: 0.5ex; padding-bottom: 0.5ex; }
|
|
47
|
-
math mtable.tml-jot mtd { padding-top: 0.7ex; padding-bottom: 0.7ex; }
|
|
77
|
+
/* ─── Correction 1: the mtd padding Temml assumes but does not set ──────────
|
|
78
|
+
Temml's sheet says "Default mtd top padding is 0.5ex per MathML-Core and
|
|
79
|
+
user-agent CSS" and only *adjusts* it for jot and small. Measured in Chrome
|
|
80
|
+
(2026-07), a pristine `mtd` gets 0px. A `pmatrix` or `cases` carries no
|
|
81
|
+
`tml-*` class at all, so nothing else covers it and its rows sit touching.
|
|
48
82
|
|
|
49
|
-
|
|
83
|
+
⚠️ Guarded to exclude Firefox, and that is load-bearing rather than cautious.
|
|
84
|
+
Temml zeroes `mtd` padding deliberately inside `@-moz-document url-prefix()`
|
|
85
|
+
("Adjust Firefox spacing between array rows"). An unguarded `math mtd` rule
|
|
86
|
+
outranks it on specificity (0,0,2 vs 0,0,1) regardless of the at-rule, so it
|
|
87
|
+
would silently undo that tuning in the one engine Temml had tuned. This is
|
|
88
|
+
the same mistake as the `.tml-right` copy above, which is why it is stated
|
|
89
|
+
here instead of being learned twice.
|
|
50
90
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
into the spans as text, and a span carrying a number is no longer :empty, so
|
|
56
|
-
the two can never both fire.
|
|
57
|
-
|
|
58
|
-
AMS auto-numbering. Which equations number is the AUTHOR's choice, made in
|
|
59
|
-
LaTeX: `align` and `equation` number, `aligned` and the starred forms do not.
|
|
60
|
-
Without these two rules that choice was discarded -- `align` and `align*`
|
|
61
|
-
rendered identically, so an author who asked for numbers silently got none. */
|
|
62
|
-
.tml-eqn:empty::before {
|
|
63
|
-
counter-increment: tmlEqnNo;
|
|
64
|
-
content: "(" counter(tmlEqnNo) ")";
|
|
65
|
-
}
|
|
66
|
-
body {
|
|
67
|
-
counter-reset: tmlEqnNo;
|
|
91
|
+
`@supports (not (-moz-appearance: none))` is Temml's own idiom for
|
|
92
|
+
"everywhere but Firefox". */
|
|
93
|
+
@supports (not (-moz-appearance: none)) {
|
|
94
|
+
math mtd { padding-top: 0.5ex; padding-bottom: 0.5ex; }
|
|
68
95
|
}
|
|
69
|
-
|
|
70
|
-
|
|
96
|
+
|
|
97
|
+
/* ─── Correction 2: let a numbered equation's TAG reach the margin ──────────
|
|
98
|
+
Display math needs CSS block layout, not MathML layout, for an equation tag
|
|
99
|
+
to sit at the right margin: the tag rides in an mtable whose `width: 100%`
|
|
71
100
|
Chromium ignores under `display: block math`, collapsing the spacer cells so
|
|
72
|
-
"(1)"
|
|
101
|
+
"(1)" ends up glued to the equation.
|
|
73
102
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
103
|
+
Temml already declares `math.tml-display { display: block; width: 100% }`,
|
|
104
|
+
and it cannot win: Temml emits `style="display:block math"` inline on every
|
|
105
|
+
display formula unconditionally, with no option to turn it off, and an inline
|
|
106
|
+
style beats any stylesheet rule. So this restores Temml's own intent with the
|
|
107
|
+
`!important` its own rule lacks.
|
|
79
108
|
|
|
80
|
-
Scoped with
|
|
81
|
-
display formula to CSS block layout would left-align the lot
|
|
82
|
-
is what centres them
|
|
83
|
-
`display: block math` and stays centred. Where
|
|
84
|
-
simply does not reach the margin; nothing else changes. */
|
|
109
|
+
Scoped with `:has()` to formulas that actually carry a tag. Switching every
|
|
110
|
+
display formula to CSS block layout would left-align the lot — MathML layout
|
|
111
|
+
is what centres them — so an unnumbered derivation or matrix keeps
|
|
112
|
+
`display: block math` and stays centred. Where `:has()` is unsupported the
|
|
113
|
+
tag simply does not reach the margin; nothing else changes. */
|
|
85
114
|
math.tml-display:has(.tml-eqn) {
|
|
86
115
|
display: block !important;
|
|
87
116
|
width: 100%;
|
|
88
117
|
}
|
|
89
|
-
|