Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
slides: LaTeX from #540 renders; \(…\)/\[…\] delimiters, multi-line display, editor hint (#550)
nyblnet50aa9277a100
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 344aca96..1867d768 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -1450,6 +1450,12 @@ jobs:# pairs with one in the text, so a link whose address carries a# dollar sign keeps its href (pre-existing since #465).run: node scripts/test-slides-math-href.ts+ - name: Maths delimiters rig+ # #540: \(…\) and \[…\] beside $…$ and $$…$$, escapes literal,+ # "$5 and $10" still prose; display maths may span <br>/<div>/<p>+ # line breaks and nothing else; the editor-only "Not rendered" hint;+ # paste and commit keep a formula's backslashes. Real engine, DOM-free.+ run: node scripts/test-slides-math-delims.ts- name: Compact document rig# The agent authoring form (#422): compactDoc/expandDoc are inverses# on the starter deck, expansion equals the editor's insert helpersdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 885035cc..f731fccd 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,6 +11,23 @@ pre-1.0.## [Unreleased]+- **Formulas that stayed as raw text now render.** 1.2.0 replaced the maths+ engine with a smaller one of our own, and a whole set of everyday LaTeX fell+ back to raw text: `\frac12`, `\over` and `\choose`, `\pmod`, `\middle|`,+ `\colon`, `\xrightarrow`, `\substack`, `\cfrac`, `\operatorname*`, `\tag`,+ `\hspace` and the other spacing commands, `\rm`/`\bf` switches, `gather`,+ `split`, `multline` and `alignat`, and symbols like `\leqslant`, `\nmid`+ and `\checkmark`. All of these render now. `\tag{1}` shows as a "(1)" label+ after the formula, not pushed to the right margin, and `\notag` and+ `\vspace` render as nothing. Formulas can also be written between `\( … \)`+ (inline) and `\[ … \]` (display), the form ChatGPT, Claude and most+ Markdown produce, and a `$$ … $$` or `\[ … \]` formula may run over several+ lines of a text box. In the editor, a formula that still does not render+ gets a faint dotted underline, with a tooltip naming the command it did not+ know. The underline only appears while editing, never in the show, in print+ or in the saved file. Pasting or editing a formula no longer drops the+ backslash from `\_`. Reported in #540.+## [1.2.3] — 2026-09-19- **Select several slides in the sidebar and move them together.** ⌘/Ctrl-clickdiff --git a/scripts/fixtures/maths-540.json b/scripts/fixtures/maths-540.jsonnew file mode 100644index 00000000..c078efb8--- /dev/null+++ b/scripts/fixtures/maths-540.json@@ -0,0 +1,19 @@+{+ "about": "Issue #540 — the commands and environments maths-lite refused while Temml rendered them (the lead's probe, plus their neighbours). The rig requires every one to render (the hard must-render list); maths-set.json carries them too so the Temml identity gate covers them.",+ "mustRender": [+ "p \\land q", "p \\lor q", "x \\gets y", "\\top", "\\bot",+ "A \\xrightarrow{f} B", "A \\xleftarrow{g} B", "A \\xleftrightarrow{h} B", "A \\xRightarrow{i} B",+ "\\frac12", "x^\\frac12", "\\frac1{2}", "\\tfrac12", "\\dfrac12",+ "a \\over b", "{a+1 \\over b}", "n \\choose k", "{n \\choose k}", "a \\atop b",+ "\\cfrac{1}{1 + \\cfrac{1}{x}}", "\\genfrac{(}{)}{0pt}{}{n}{k}", "\\dbinom{n}{k}", "\\tbinom{n}{k}",+ "\\dagger", "\\ddagger", "a \\nmid b", "a \\nparallel b", "\\square", "\\blacksquare", "\\checkmark",+ "f \\colon A \\to B", "a \\leqslant b", "a \\geqslant b", "a \\lesssim b", "a \\gtrsim b",+ "A \\varsubsetneq B", "A \\subsetneq B", "A \\supsetneq B", "A \\nsubseteq B",+ "a \\bmod n", "a \\equiv b \\pmod{n}", "a \\equiv b \\pod{n}", "a \\equiv b \\mod{n}",+ "\\sum_{\\substack{i < n \\\\ j < m}} a_{ij}", "\\left\\{ x \\middle| x > 0 \\right\\}",+ "\\mathring{A}", "a \\mathbin{\\star} b", "a \\mathrel{\\sim} b", "\\mathop{\\rm Res} f", "\\mathord{+}",+ "\\operatorname*{argmax}_x f(x)", "\\emph{note} x", "a \\hspace{1em} b", "a \\vspace{1em} b", "x_1, \\dotsc, x_n", "x_1 + \\dotsb + x_n",+ "\\begin{multline} a + b \\\\ + c \\end{multline}", "\\begin{eqnarray} a &=& b \\\\ c &=& d \\end{eqnarray}",+ "a = b \\tag{1}", "a = b \\notag", "a = b \\nonumber"+ ]+}diff --git a/scripts/fixtures/maths-reference.json b/scripts/fixtures/maths-reference.jsonindex eecec9f0..c0b4abd6 100644--- a/scripts/fixtures/maths-reference.json+++ b/scripts/fixtures/maths-reference.json@@ -1,6 +1,6 @@{"temml": "0.13.3",- "frozen": "2026-09-15",+ "frozen": "2026-09-24","formulas": [{"src": "ax^2 + bx + c = 0",@@ -547,6 +547,372 @@"display": true,"from": "standard","tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"σ\"}]},{\"tag\":\"msub\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"(\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"z\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\")\"}]}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"i\"}]}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"=\"}]},{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"msup\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"e\"}]},{\"tag\":\"msub\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"z\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"i\"}]}]}]},{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"msubsup\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"∑\"}]},{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"j\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"=\"}]},{\"tag\":\"mn\",\"kids\":[{\"t\":\"1\"}]}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"K\"}]}]},{\"tag\":\"msup\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"e\"}]},{\"tag\":\"msub\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"z\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"j\"}]}]}]}]}]}]}]}"+ },+ {+ "src": "p \\land q",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"p\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"∧\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"q\"}]}]}]}"+ },+ {+ "src": "p \\lor q",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"p\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"∨\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"q\"}]}]}]}"+ },+ {+ "src": "x \\gets y",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"x\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"←\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"y\"}]}]}]}"+ },+ {+ "src": "\\top",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"⊤\"}]}]}"+ },+ {+ "src": "\\bot",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"⊥\"}]}]}"+ },+ {+ "src": "A \\xrightarrow{f} B",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"A\"}]},{\"tag\":\"mover\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"→\"}]},{\"tag\":\"mover\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"f\"}]}]}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"B\"}]}]}]}"+ },+ {+ "src": "A \\xleftarrow{g} B",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"A\"}]},{\"tag\":\"mover\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"←\"}]},{\"tag\":\"mover\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"g\"}]}]}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"B\"}]}]}]}"+ },+ {+ "src": "A \\xleftrightarrow{h} B",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"A\"}]},{\"tag\":\"mover\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"↔\"}]},{\"tag\":\"mover\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"h\"}]}]}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"B\"}]}]}]}"+ },+ {+ "src": "A \\xRightarrow{i} B",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"A\"}]},{\"tag\":\"mover\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"⇒\"}]},{\"tag\":\"mover\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"i\"}]}]}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"B\"}]}]}]}"+ },+ {+ "src": "\\frac12",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mn\",\"kids\":[{\"t\":\"1\"}]},{\"tag\":\"mn\",\"kids\":[{\"t\":\"2\"}]}]}]}"+ },+ {+ "src": "x^\\frac12",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"msup\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"x\"}]},{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mn\",\"kids\":[{\"t\":\"1\"}]},{\"tag\":\"mn\",\"kids\":[{\"t\":\"2\"}]}]}]}]}"+ },+ {+ "src": "\\frac1{2}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mn\",\"kids\":[{\"t\":\"1\"}]},{\"tag\":\"mn\",\"kids\":[{\"t\":\"2\"}]}]}]}"+ },+ {+ "src": "\\tfrac12",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mn\",\"kids\":[{\"t\":\"1\"}]},{\"tag\":\"mn\",\"kids\":[{\"t\":\"2\"}]}]}]}"+ },+ {+ "src": "\\dfrac12",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mn\",\"kids\":[{\"t\":\"1\"}]},{\"tag\":\"mn\",\"kids\":[{\"t\":\"2\"}]}]}]}"+ },+ {+ "src": "a \\over b",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "{a+1 \\over b}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"+\"}]},{\"tag\":\"mn\",\"kids\":[{\"t\":\"1\"}]}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "n \\choose k",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"(\"}]},{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"n\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"k\"}]}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\")\"}]}]}]}"+ },+ {+ "src": "{n \\choose k}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"(\"}]},{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"n\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"k\"}]}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\")\"}]}]}]}"+ },+ {+ "src": "a \\atop b",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "\\cfrac{1}{1 + \\cfrac{1}{x}}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mn\",\"kids\":[{\"t\":\"1\"}]},{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mn\",\"kids\":[{\"t\":\"1\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"+\"}]},{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mn\",\"kids\":[{\"t\":\"1\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"x\"}]}]}]}]}]}"+ },+ {+ "src": "\\genfrac{(}{)}{0pt}{}{n}{k}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"(\"}]},{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"n\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"k\"}]}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\")\"}]}]}]}"+ },+ {+ "src": "\\dbinom{n}{k}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"(\"}]},{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"n\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"k\"}]}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\")\"}]}]}]}"+ },+ {+ "src": "\\tbinom{n}{k}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"(\"}]},{\"tag\":\"mfrac\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"n\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"k\"}]}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\")\"}]}]}]}"+ },+ {+ "src": "\\dagger",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"†\"}]}]}"+ },+ {+ "src": "\\ddagger",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"‡\"}]}]}"+ },+ {+ "src": "a \\nmid b",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"∤\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "a \\nparallel b",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"∦\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "\\square",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"□\"}]}]}"+ },+ {+ "src": "\\blacksquare",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"■\"}]}]}"+ },+ {+ "src": "\\checkmark",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"✓\"}]}]}"+ },+ {+ "src": "f \\colon A \\to B",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"f\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\":\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"A\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"→\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"B\"}]}]}]}"+ },+ {+ "src": "a \\leqslant b",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"⩽\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "a \\geqslant b",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"⩾\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "a \\lesssim b",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"≲\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "a \\gtrsim b",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"≳\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "A \\varsubsetneq B",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"A\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"⊊︀\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"B\"}]}]}]}"+ },+ {+ "src": "A \\subsetneq B",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"A\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"⊊\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"B\"}]}]}]}"+ },+ {+ "src": "A \\supsetneq B",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"A\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"⊋\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"B\"}]}]}]}"+ },+ {+ "src": "A \\nsubseteq B",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"A\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"⊈\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"B\"}]}]}]}"+ },+ {+ "src": "a \\bmod n",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"mod\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"n\"}]}]}]}"+ },+ {+ "src": "a \\equiv b \\pmod{n}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"≡\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]},{\"tag\":\"mo\",\"kids\":[]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"(\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"mod\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"n\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\")\"}]}]}]}"+ },+ {+ "src": "a \\equiv b \\pod{n}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"≡\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]},{\"tag\":\"mo\",\"kids\":[]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"(\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"n\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\")\"}]}]}]}"+ },+ {+ "src": "a \\equiv b \\mod{n}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"≡\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]},{\"tag\":\"mo\",\"kids\":[]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"mod\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"n\"}]}]}]}"+ },+ {+ "src": "\\sum_{\\substack{i < n \\\\ j < m}} a_{ij}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"msub\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"∑\"}]},{\"tag\":\"mtable\",\"kids\":[{\"tag\":\"mtr\",\"kids\":[{\"tag\":\"mtd\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"i\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"<\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"n\"}]}]}]}]},{\"tag\":\"mtr\",\"kids\":[{\"tag\":\"mtd\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"j\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"<\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"m\"}]}]}]}]}]}]},{\"tag\":\"msub\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"i\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"j\"}]}]}]}]}]}"+ },+ {+ "src": "\\left\\{ x \\middle| x > 0 \\right\\}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"{\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"x\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"|\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"x\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\">\"}]},{\"tag\":\"mn\",\"kids\":[{\"t\":\"0\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"}\"}]}]}]}"+ },+ {+ "src": "\\mathring{A}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mover\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"A\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"˚\"}]}]}]}"+ },+ {+ "src": "a \\mathbin{\\star} b",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"⋆\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "a \\mathrel{\\sim} b",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"∼\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "\\mathop{\\rm Res} f",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"Res\"}]}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"f\"}]}]}]}"+ },+ {+ "src": "\\mathord{+}",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"+\"}]}]}"+ },+ {+ "src": "\\operatorname*{argmax}_x f(x)",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"msub\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"argmax\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"x\"}]}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"f\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"(\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"x\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\")\"}]}]}]}"+ },+ {+ "src": "\\emph{note} x",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mtext\",\"kids\":[{\"t\":\"𝑛𝑜𝑡𝑒\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"x\"}]}]}]}"+ },+ {+ "src": "a \\hspace{1em} b",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "a \\vspace{1em} b",+ "display": false,+ "from": "issue:540",+ "tree": null+ },+ {+ "src": "x_1, \\dotsc, x_n",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"msub\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"x\"}]},{\"tag\":\"mn\",\"kids\":[{\"t\":\"1\"}]}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\",\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"…\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\",\"}]},{\"tag\":\"msub\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"x\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"n\"}]}]}]}]}"+ },+ {+ "src": "x_1 + \\dotsb + x_n",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"msub\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"x\"}]},{\"tag\":\"mn\",\"kids\":[{\"t\":\"1\"}]}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"+\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"⋯\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"+\"}]},{\"tag\":\"msub\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"x\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"n\"}]}]}]}]}"+ },+ {+ "src": "\\begin{multline} a + b \\\\ + c \\end{multline}",+ "display": true,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mtable\",\"kids\":[{\"tag\":\"mtr\",\"kids\":[{\"tag\":\"mtd\",\"kids\":[]},{\"tag\":\"mtd\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"+\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]},{\"tag\":\"mtd\",\"kids\":[{\"tag\":\"mtext\",\"kids\":[{\"tag\":\"span\",\"kids\":[]}]}]}]},{\"tag\":\"mtr\",\"kids\":[{\"tag\":\"mtd\",\"kids\":[]},{\"tag\":\"mtd\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mo\",\"kids\":[{\"t\":\"+\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"c\"}]}]}]},{\"tag\":\"mtd\",\"kids\":[{\"tag\":\"mtext\",\"kids\":[{\"tag\":\"span\",\"kids\":[]}]}]}]}]}]}"+ },+ {+ "src": "\\begin{eqnarray} a &=& b \\\\ c &=& d \\end{eqnarray}",+ "display": true,+ "from": "issue:540",+ "tree": null+ },+ {+ "src": "a = b \\tag{1}",+ "display": false,+ "from": "issue:540",+ "tree": null+ },+ {+ "src": "a = b \\notag",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"=\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"+ },+ {+ "src": "a = b \\nonumber",+ "display": false,+ "from": "issue:540",+ "tree": "{\"tag\":\"math\",\"kids\":[{\"tag\":\"mrow\",\"kids\":[{\"tag\":\"mi\",\"kids\":[{\"t\":\"a\"}]},{\"tag\":\"mo\",\"kids\":[{\"t\":\"=\"}]},{\"tag\":\"mi\",\"kids\":[{\"t\":\"b\"}]}]}]}"}]}diff --git a/scripts/fixtures/maths-set.json b/scripts/fixtures/maths-set.jsonindex f53358f5..405d1799 100644--- a/scripts/fixtures/maths-set.json+++ b/scripts/fixtures/maths-set.json@@ -453,5 +453,310 @@"src": "\\sigma(z)_i = \\frac{e^{z_i}}{\\sum_{j=1}^K e^{z_j}}","display": true,"from": "standard"+ },+ {+ "src": "p \\land q",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "p \\lor q",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "x \\gets y",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\top",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\bot",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "A \\xrightarrow{f} B",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "A \\xleftarrow{g} B",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "A \\xleftrightarrow{h} B",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "A \\xRightarrow{i} B",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\frac12",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "x^\\frac12",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\frac1{2}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\tfrac12",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\dfrac12",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\over b",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "{a+1 \\over b}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "n \\choose k",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "{n \\choose k}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\atop b",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\cfrac{1}{1 + \\cfrac{1}{x}}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\genfrac{(}{)}{0pt}{}{n}{k}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\dbinom{n}{k}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\tbinom{n}{k}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\dagger",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\ddagger",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\nmid b",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\nparallel b",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\square",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\blacksquare",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\checkmark",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "f \\colon A \\to B",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\leqslant b",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\geqslant b",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\lesssim b",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\gtrsim b",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "A \\varsubsetneq B",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "A \\subsetneq B",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "A \\supsetneq B",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "A \\nsubseteq B",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\bmod n",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\equiv b \\pmod{n}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\equiv b \\pod{n}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\equiv b \\mod{n}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\sum_{\\substack{i < n \\\\ j < m}} a_{ij}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\left\\{ x \\middle| x > 0 \\right\\}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\mathring{A}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\mathbin{\\star} b",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\mathrel{\\sim} b",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\mathop{\\rm Res} f",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\mathord{+}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\operatorname*{argmax}_x f(x)",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\emph{note} x",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\hspace{1em} b",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a \\vspace{1em} b",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "x_1, \\dotsc, x_n",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "x_1 + \\dotsb + x_n",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "\\begin{multline} a + b \\\\ + c \\end{multline}",+ "display": true,+ "from": "issue:540"+ },+ {+ "src": "\\begin{eqnarray} a &=& b \\\\ c &=& d \\end{eqnarray}",+ "display": true,+ "from": "issue:540"+ },+ {+ "src": "a = b \\tag{1}",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a = b \\notag",+ "display": false,+ "from": "issue:540"+ },+ {+ "src": "a = b \\nonumber",+ "display": false,+ "from": "issue:540"}-]\ No newline at end of file+]diff --git a/scripts/test-maths-lite.ts b/scripts/test-maths-lite.tsindex b3d41026..3f07f5b6 100644--- a/scripts/test-maths-lite.ts+++ b/scripts/test-maths-lite.ts@@ -51,28 +51,62 @@ ok(renderMath('') === null || renderMath('') === '<math xmlns="http://www.w3.orgconsole.log('\nthe reference set, against the frozen Temml trees\n')type Ref = { src: string; display: boolean; from: string; tree: string | null }const reference = JSON.parse(readFileSync(join(root, 'scripts/fixtures/maths-reference.json'), 'utf8')) as { temml: string; frozen: string; formulas: Ref[] }-ok(reference.formulas.length === 91 && reference.temml === '0.13.3', `the reference is the spike's 91-formula set, frozen from Temml ${reference.temml} on ${reference.frozen}`)+ok(reference.formulas.length === 152 && reference.temml === '0.13.3', `the reference is the spike's 91 formulas plus issue #540's 61, frozen from Temml ${reference.temml} on ${reference.frozen}`)const corpus = reference.formulas.filter((f) => f.from.startsWith('corpus:') && !f.src.includes('…'))ok(corpus.length >= 9 && corpus.every((c) => renderMath(c.src, { display: c.display }) !== null), `every formula our decks and rigs carry renders (${corpus.length})`)// Known residuals -- each one a place where Temml's tree is NOT what we want:// menclose is blank on Chrome (we draw the rule), and one extra mrow level// with 0.0% pixel difference. Anything else that differs is a regression.-const RESIDUAL = new Set(['\\overline{AB}', '\\underline{x}', '\\sigma(z)_i = \\frac{e^{z_i}}{\\sum_{j=1}^K e^{z_j}}'])+const RESIDUAL = new Set(['\\overline{AB}', '\\underline{x}', '\\sigma(z)_i = \\frac{e^{z_i}}{\\sum_{j=1}^K e^{z_j}}',+ // #540: Temml wraps a \mathop word as <mo><mi>Res</mi></mo>; ours is the+ // function-name <mi>, which spaces the same and is valid MathML+ '\\mathop{\\rm Res} f',+ // #540: Temml's multline is three columns with an equation-number <span>+ // in the third (its stylesheet, which Bento never loads, positions it);+ // ours is the one column of lines, centred like every Bento table+ '\\begin{multline} a + b \\\\ + c \\end{multline}'])+// Where maths-lite deliberately renders what Temml refused (#540): \vspace+// is dropped (a slide formula has no vertical flow to space), eqnarray is+// aligned like align, and \tag outside display mode is still a label+const BEYOND_TEMML = new Set(['a \\vspace{1em} b', '\\begin{eqnarray} a &=& b \\\\ c &=& d \\end{eqnarray}', 'a = b \\tag{1}'])let both = 0, same = 0const unexpected: string[] = []for (const f of reference.formulas) {const lite = renderMath(f.src, { display: f.display })const key = lite ? treeKey(lite) : null- if (!f.tree || !key) { if (!!f.tree !== !!key) unexpected.push(`${f.src} (temml ${!!f.tree}, ours ${!!key})`); continue }+ if (!f.tree || !key) { if (!!f.tree !== !!key && !(key && BEYOND_TEMML.has(f.src))) unexpected.push(`${f.src} (temml ${!!f.tree}, ours ${!!key})`); continue }both++if (key === f.tree) same++else if (!RESIDUAL.has(f.src)) unexpected.push(f.src)}-ok(both === 89, '89 formulas render in both (the two refused are the canvas placeholder hint, refused by both)')+ok(both === 147, '147 formulas render in both (refused by both: the canvas placeholder hint, twice; three render only here — BEYOND_TEMML)')ok(same / both >= 0.95, `>=95% identical normalised trees: ${same}/${both} = ${(100 * same / both).toFixed(1)}%`)ok(unexpected.length === 0, `every mismatch is a listed residual -- unexpected: ${unexpected.join(' · ') || 'none'}`)ok(both - same === RESIDUAL.size, `and every listed residual still differs (${both - same} of ${RESIDUAL.size}) -- remove one from the list when it is closed`)+// THE HARD LIST (#540). The 95% gate let 57 commands Temml rendered fall+// back to raw text in 1.2.0 — a percentage cannot see a regression that is+// small against the whole set. Every formula here must render: one null and+// this goes red, whatever the percentage says.+const hard = JSON.parse(readFileSync(join(root, 'scripts/fixtures/maths-540.json'), 'utf8')) as { mustRender: string[] }+const nulls = hard.mustRender.filter((src) => renderMath(src, { display: /\\begin\{(multline|eqnarray)\}/.test(src) }) === null)+ok(hard.mustRender.length === 61 && nulls.length === 0, `every must-render formula renders (${hard.mustRender.length - nulls.length}/${hard.mustRender.length})${nulls.length ? ' — null: ' + nulls.join(' · ') : ''}`)+ok(hard.mustRender.every((src) => reference.formulas.some((f) => f.src === src)), 'and every one is in the frozen reference, so its tree is gated too')++console.log('\n#540: the shapes the new commands take\n')+ok(renderMath('\\frac12')!.includes('<mfrac><mn>1</mn><mn>2</mn></mfrac>') && renderMath('\\sqrt2')!.includes('<msqrt><mn>2</mn></msqrt>'), 'a macro argument is ONE token: \\frac12 is ½, \\sqrt2 is √2')+ok(renderMath('12')!.includes('<mn>12</mn>'), '…while 12 in a row stays the number twelve')+ok(renderMath('{a+1 \\over b}')!.includes('<mfrac><mrow><mi>a</mi><mo>+</mo><mn>1</mn></mrow><mi>b</mi></mfrac>'), '\\over splits the whole group')+ok(renderMath('n \\choose k')!.includes('stretchy="true">(</mo><mfrac linethickness="0">'), '\\choose is a binomial')+ok(renderMath('A \\xrightarrow[u]{o} B')!.includes('<munderover><mo stretchy="true" lspace="0em" rspace="0em">→</mo>'), '\\xrightarrow[under]{over} labels both sides')+ok(renderMath('a \\equiv b \\pmod{n}')!.includes('<mi>mod</mi>'), '\\pmod writes (mod n)')+ok(renderMath('\\left\\{ x \\middle| x > 0 \\right\\}')!.includes('<mo lspace="0.05em" rspace="0.05em" stretchy="true">|</mo>'), '\\middle| is one stretchy bar')+ok(renderMath('f \\colon A \\to B')!.includes('<mo lspace="0em" rspace="0.1667em">:</mo>'), '\\colon: no space before, a thin one after')+ok(renderMath('a = b \\tag{1}')!.includes('<mtext>(1)</mtext>') && renderMath('a = b \\tag*{A}')!.includes('<mtext>A</mtext>'), '\\tag is a label after the formula, in parentheses; \\tag* without')+ok(renderMath('a = b \\notag') === renderMath('a = b') && renderMath('a \\vspace{2em} b') === renderMath('a b'), '\\notag, \\nonumber and \\vspace render as nothing')+ok(renderMath('\\operatorname*{argmax}_x f', { display: true })!.includes('<munder>') && renderMath('\\operatorname*{argmax}_x f')!.includes('<msub>'), '\\operatorname*: limits under in display, at the side inline')+ok(renderMath('\\emph{note}')!.includes('<mtext>𝑛𝑜𝑡𝑒</mtext>'), '\\emph is italic text')+console.log('\nMathML shape\n')const q = renderMath('x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}', { display: true })!ok(q.startsWith('<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">'), 'display mode sets display="block"')diff --git a/scripts/test-slides-math-delims.ts b/scripts/test-slides-math-delims.tsnew file mode 100644index 00000000..bab62c6c--- /dev/null+++ b/scripts/test-slides-math-delims.ts@@ -0,0 +1,111 @@+#!/usr/bin/env node+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento authors+// Where formulas are found in a text box: the four delimiters, display maths+// across line breaks, and the editor's "not rendered" hint (#540).+//+// node scripts/test-slides-math-delims.ts+//+// WHAT THIS PROVES. 1.2.0 read only `$…$` and `$$…$$`, and only inside one+// text run, so three things a reporter pasted stayed raw:+// - `\(…\)` and `\[…\]`, the delimiters ChatGPT, Claude and most Markdown+// emit;+// - a `$$ … $$` typed over several lines — Enter in a text box puts <br> or+// <div> between the lines, and the formula was never one text run;+// - and nothing told the author WHY a formula stayed raw.+// slides/src/maths/delimiters.ts is DOM-free, so this drives the code render.ts+// runs, with the real engine behind it. The #465 guarantee (a formula never+// enters or crosses a tag other than a line break) is re-proved here for the+// new forms; test-slides-math-href.ts keeps the original cases.+//+// The paste and commit paths are here too: markdown's escape stripping and+// emphasis rules must not reach inside a formula, or `\_` (LaTeX's literal+// underscore) lost its backslash when the text box was committed.++import { resolveMathHtml } from '../slides/src/maths/delimiters.ts'+import { renderMath, mathError } from '../slides/src/maths/index.ts'+import { markdownToHtml, stripMarkerEscapes } from '../slides/src/editor/markdown.ts'++let failures = 0+let checks = 0+function ok(cond: boolean, msg: string) {+ checks+++ if (!cond) { failures++; console.log(` FAIL ${msg}`) }+ else console.log(` ok ${msg}`)+}++const engine = (src: string, display: boolean) => renderMath(src, { display })+const hint = (src: string, display: boolean, spaced?: boolean) =>+ spaced ? 'Not rendered: spaces' : ((why) => (why ? `Not rendered: ${why}` : null))(mathError(src, { display }))+const resolve = (html: string) => resolveMathHtml(html, engine)+const hinted = (html: string) => resolveMathHtml(html, engine, hint)+const inline = (src: string) => renderMath(src, { display: false })!+const display = (src: string) => renderMath(src, { display: true })!+const maths = (html: string) => (html.match(/<math\b/g) ?? []).length++console.log('the four delimiters\n')+ok(resolve('area \\(\\pi r^2\\) here') === `area ${inline('\\pi r^2')} here`, '\\(…\\) is inline maths')+ok(resolve('\\[\\int_0^1 x\\,dx\\]') === display('\\int_0^1 x\\,dx'), '\\[…\\] is display maths')+ok(resolve('$x^2$ and $$y^2$$') === `${inline('x^2')} and ${display('y^2')}`, '$…$ and $$…$$ as before')+ok(resolve('\\(a\\)\\(b\\)') === inline('a') + inline('b'), 'two \\(…\\) back to back both render')+ok(resolve('\\(a\\) costs $5') === `${inline('a')} costs $5`, 'a lone price beside a formula stays a price')+ok(resolve('\\[ \\sum_{i=1}^n i \\]') === display(' \\sum_{i=1}^n i '), 'spaces inside \\[ \\] are fine — only $…$ is fussy')++console.log('\nescapes stay literal\n')+ok(resolve('\\\\(x\\\\)') === '\\(x\\)', '\\\\( … \\\\) shows \\( … \\) as typed')+ok(resolve('\\\\[x\\\\]') === '\\[x\\]', '\\\\[ … \\\\] shows \\[ … \\]')+ok(resolve('\\$x\\$') === '$x$', '\\$ is a dollar, as before')+ok(resolve('\\(\\$5\\)') === inline('\\$5'), 'an escaped dollar inside \\(…\\) is the formula\'s own')++console.log('\nprose stays prose\n')+ok(resolve('it costs $5 and $10') === 'it costs $5 and $10', '"$5 and $10" is not a formula')+ok(resolve('$ x^2 $') === '$ x^2 $', '$ x^2 $ with spaces inside stays prose, by design')+ok(resolve('(see note) [1]') === '(see note) [1]', 'plain parentheses and brackets are untouched')+ok(resolve('a\\(b') === 'a\\(b', 'an unclosed \\( is left as typed')++console.log('\nnever inside a tag (#465)\n')+const link = '<a href="https://x.example/\\(a\\)$b$">link</a>'+ok(resolve(link) === link, 'delimiters of every kind inside an href are untouched')+ok(resolve(`${link} and \\(x\\)`) === `${link} and ${inline('x')}`, 'a formula beside the link renders; the href is whole')+ok(resolve('<img alt="\\[x\\]">') === '<img alt="\\[x\\]">', 'any attribute, not just href')+ok(resolve('\\(a <b>b\\)</b>') === '\\(a <b>b\\)</b>', 'an inline pair split by a tag does not pair')+ok(resolve('$$a <b>b</b> c$$') === '$$a <b>b</b> c$$', 'a display pair split by a tag that is not a line break does not pair')++console.log('\ndisplay maths across line breaks\n')+const two = display('a = b\n+ c')+ok(resolve('$$a = b<br>+ c$$') === two, '$$ … <br> … $$ joins the lines and renders once')+ok(resolve('\\[a = b<br>+ c\\]') === two, '\\[ … <br> … \\] too')+ok(resolve('x<div>$$a = b</div><div>+ c$$</div>') === `x<div><div>${two}</div></div>`, 'across <div> lines: the swallowed tags are put back balanced around the formula')+ok(resolve('<p>$$a = b</p><p>+ c$$</p>') === `<p><p>${two}</p></p>`, 'across <p> lines')+ok(resolve('$$\\begin{aligned} a &= b \\\\<br> c &= d \\end{aligned}$$') === display('\\begin{aligned} a &= b \\\\\n c &= d \\end{aligned}'), 'an aligned block typed one row per line')+ok(resolve('before $$a<br>b$$ after $x$') === `before ${display('a\nb')} after ${inline('x')}`, 'text before and after a spanned formula carries on, and later formulas still render')+ok(resolve('$$a<b>b</b><br>c$$') === '$$a<b>b</b><br>c$$', 'a span meeting any other tag stays raw — a formula never crosses <b>')+ok(resolve('$$a<div>b</p>c$$') === '$$a<div>b</p>c$$', '<div> and <p> are never mixed in one span')+ok(resolve('$$a<br>b') === '$$a<br>b', 'an opener with no closer is left as typed')+ok(resolve('$$a$$<br>$$b$$') === `${display('a')}<br>${display('b')}`, 'two one-line formulas are not mistaken for one span')+ok(resolve('$$\\foo<br>b$$') === '$$\\foo<br>b$$', 'a span that does not render is left as typed')++console.log('\nthe editor hint\n')+ok(resolve('$\\foo$') === '$\\foo$' && maths(resolve('$\\foo$')) === 0, 'without a hint function nothing is marked — thumbnails, present, print, the static preview')+ok(hinted('$\\foo x$') === '<span class="bento-math-miss" title="Not rendered: \\foo">$\\foo x$</span>', 'an unknown command is named in the title, the text stays as typed')+ok(hinted('\\(\\bar{\\foo}\\)').includes('title="Not rendered: \\foo"'), 'the FIRST unknown command')+ok(hinted('\\[a^{b\\]').includes('class="bento-math-miss"'), 'a \\[…\\] that fails is marked')+ok(hinted('$ x^2 $') === '<span class="bento-math-miss" title="Not rendered: spaces">$ x^2 $</span>', '$ x^2 $ is marked with the spaces reason')+ok(hinted('it costs $5 and $10') === 'it costs $5 and $10', 'prices are never marked')+ok(hinted('a $b c$ d') === resolve('a $b c$ d'), 'a formula that renders is not marked')+ok(hinted('$x} and {y$') === '$x} and {y$', 'a failed $…$ that does not look like maths (no \\, ^ or _) is not marked')+ok(hinted('<a href="$\\foo$">x</a>') === '<a href="$\\foo$">x</a>', 'no hint inside an attribute')+ok(hinted('\\(\\foo "x"\\)').includes('>\\(\\foo "x"\\)</span>') && !/title="[^"]*"x"/.test(hinted('\\(\\foo "x"\\)')), 'the title is escaped')+ok(hinted('$$\\foo$$ then $x$') === `<span class="bento-math-miss" title="Not rendered: \\foo">$$\\foo$$</span> then ${inline('x')}`, 'a marked miss is closed off: its dollars never pair with a later one')++console.log('\npaste and commit keep backslashes in formulas\n')+ok(stripMarkerEscapes('\\*not bold\\*') === '*not bold*', 'outside a formula a markdown escape still drops its backslash')+ok(stripMarkerEscapes('$\\text{a\\_b}$ and \\_') === '$\\text{a\\_b}$ and _', 'inside $…$ the \\_ is LaTeX and keeps it')+ok(stripMarkerEscapes('\\(a\\_b\\) \\[c\\*\\]') === '\\(a\\_b\\) \\[c\\*\\]', 'inside \\(…\\) and \\[…\\] too')+ok(markdownToHtml('\\(x^* + y^*\\)') === '\\(x^* + y^*\\)', 'a pasted formula is not read as emphasis')+ok(markdownToHtml('see \\(\\frac{a}{b}\\) and $a\\_1$') === 'see \\(\\frac{a}{b}\\) and $a\\_1$', 'pasted \\( and \\_ keep their backslashes')+ok(markdownToHtml('$a < b$ **bold**') === '$a < b$ <b>bold</b>', 'a parked formula is still HTML-escaped, and markdown outside it still works')+ok(resolve(markdownToHtml('\\[\\sum_i x_i\\]')) === display('\\sum_i x_i'), 'pasted, then rendered: the whole round trip')++console.log(`\n${checks - failures}/${checks} checks passed`)+process.exit(failures ? 1 : 0)diff --git a/scripts/test-slides-math-href.ts b/scripts/test-slides-math-href.tsindex 12a4868a..2659ed70 100644--- a/scripts/test-slides-math-href.ts+++ b/scripts/test-slides-math-href.ts@@ -18,11 +18,14 @@// the link intact and clickable with `$x^2$` rendering beside it.//// render.ts is not node-importable (DOM), so the rig holds the SOURCE to the-// split and drives the split's behaviour with the same regexes.+// split and drives the split's behaviour with the same regexes. Since #540+// the split lives in slides/src/maths/delimiters.ts, which is DOM-free, so+// the rig now drives that code itself rather than a copy of its regexes.import { readFileSync } from 'node:fs'import { fileURLToPath } from 'node:url'import { dirname, join } from 'node:path'+import { resolveMathHtml } from '../slides/src/maths/delimiters.ts'let failures = 0let checks = 0@@ -33,24 +36,19 @@ function ok(cond: boolean, msg: string) {}const root = join(dirname(fileURLToPath(import.meta.url)), '..')const render = readFileSync(join(root, 'slides/src/render.ts'), 'utf8')+const delims = readFileSync(join(root, 'slides/src/maths/delimiters.ts'), 'utf8')console.log('the source\n')-const rm = render.slice(render.indexOf('export function resolveMath'), render.indexOf('export function resolveMath') + 1600)-ok(/html\.split\(\/\(<\[\^>\]\*>\)\/\)\.map\(\(part, i\) => \(i % 2 \? part : resolveMathText\(part\)\)\)\.join\(''\)/.test(rm), 'resolveMath splits on tags and hands only the text runs to resolveMathText')-ok(/function resolveMathText\(text: string\)/.test(render), 'the $$/$ rules live on the text-run function')-ok(!/html\.replace\(\/\(\^\|\[\^\\\\\]\)\\\$\\\$/.test(rm), 'no rule runs over the whole HTML any more')-ok(/\$\$…\$\$ first \(display\), then \$…\$ \(inline\)/.test(rm), 'the fussy inline rule is unchanged (no whitespace inside, no digit after)')+ok(/export function resolveMath\(html: string, hint\?[^)]*\)[^{]*\{\s*return resolveMathHtml\(html, renderMath,/.test(render), 'render.ts resolveMath hands the html to resolveMathHtml')+ok(/const parts = html\.split\(\/\(<\[\^>\]\*>\)\/\)/.test(delims) && /parts\.map\(\(p, i\) => \(i % 2 \? p : resolveRun\(/.test(delims), 'resolveMathHtml splits on tags and hands only the text runs to resolveRun')+ok(!/html\.replace\(/.test(delims), 'no rule runs over the whole HTML')+ok(delims.includes("/(^|[^\\\\$])\\$(\\S(?:[^$\\n]*?\\S)?)\\$(?!\\d)/g"), 'the fussy inline rule is unchanged (no whitespace inside, no digit after)')-console.log('\nthe behaviour, with the same split and a stand-in renderer\n')+console.log('\nthe behaviour, with the real split and a stand-in renderer\n')// the stand-in: any source becomes a <math> stub — what matters is WHERE the// rules are allowed to look, not what the engine printsconst stub = (src: string) => `<math>${src}</math>`-const text = (t: string) => {- let out = t.replace(/(^|[^\\])\$\$([^$]+?)\$\$/g, (_m, pre: string, src: string) => pre + stub(src))- out = out.replace(/(^|[^\\$])\$(\S(?:[^$\n]*?\S)?)\$(?!\d)/g, (_m, pre: string, src: string) => pre + stub(src))- return out.replace(/\\\$/g, '$')-}-const resolve = (html: string) => html.split(/(<[^>]*>)/).map((p, i) => (i % 2 ? p : text(p))).join('')+const resolve = (html: string) => resolveMathHtml(html, stub)const link = '<a href="https://x.example/$a$b" rel="noopener">link</a>'ok(resolve(link) === link, 'a $ pair inside an href is untouched — the link is intact')diff --git a/slides/src/editor/canvas.ts b/slides/src/editor/canvas.tsindex 0562f52f..e6c40b47 100644--- a/slides/src/editor/canvas.ts+++ b/slides/src/editor/canvas.ts@@ -10,7 +10,7 @@ import type { Store } from '../store'import { t } from '../i18n'import { defaultShape, internAsset, readableInk, uid, type ShapeElement, type SlideElement, type TableElement } from '../model'import { renderSlide, sanitizeHtml } from '../render'-import { autoformatAtCaret, clearAutoformat, markdownToHtml, undoAutoformat } from './markdown'+import { autoformatAtCaret, clearAutoformat, markdownToHtml, stripMarkerEscapes, undoAutoformat } from './markdown'import { bulletsToLists } from './bullets'import { clipboardToHtml } from './paste'import { execFormat, hideFormatBar, syncFormatBar } from './richtext'@@ -32,6 +32,11 @@ const TAP_SLOP = 10/** …and how long it may rest. Past this it is a press, not a tap. */const TAP_HOLD_MS = 700+/** The title on an unrendered formula (render.ts mathHint): what went wrong,+ * translated at call time — `\\foo` is shown as typed. */+const mathHintTitle = (what: string) =>+ t('Not rendered: {what}', { what: what === 'spaces' ? t('no space just inside the $ signs') : what })+export class SlideCanvas {private stage: HTMLElementprivate scaleHost: HTMLElement@@ -851,7 +856,8 @@ export class SlideCanvas {if (this.pathEditor?.active) this.pathEditor.cancel() // doc changed under usif (this.cropEditor?.active) this.cropEditor.cancel()const slide = this.store.slide- const next = renderSlide(slide, this.store.doc)+ // the canvas alone marks a formula that did not render (#540)+ const next = renderSlide(slide, this.store.doc, { mathHint: mathHintTitle })// hover-reveal slides: preview one set at a time; hidden sets are// display:none so they don't block selectionconst sets = [...new Set(slide.elements.map((e) => e.showOnHover).filter(Boolean))] as string[]@@ -1404,7 +1410,9 @@ export class SlideCanvas {// Remember that we swapped: on commit the resolved view has to be put back// even when the text did NOT change, and only a re-render can do that.this.editingShowedRaw = false- if (model?.type === 'text' && typeof model.html === 'string' && /\{\{|\$/.test(model.html)) {+ // (`\(` and `\[` open formulas too, #540 — and an unrendered one wears the+ // editor's hint span, which must never be what the author edits)+ if (model?.type === 'text' && typeof model.html === 'string' && /\{\{|\$|\\[([]/.test(model.html)) {// SANITIZED, even though the point of the swap is to show what the model// holds. This is the only place raw model html reaches the live canvas —// the render path has always cleaned it — so without this, double-@@ -1503,7 +1511,7 @@ export class SlideCanvas {// typed "- " bullets are glyphs while you type (markdown.ts says why);// once the edit ends they become real list items, so a long bullet wraps// under its text rather than under the glyph (#502, editor/bullets.ts)- const html = bulletsToLists(sanitizeHtml(inner.innerHTML.replace(/\u200B/g, '').replace(/\\([*_~`-])/g, '$1')))+ const html = bulletsToLists(sanitizeHtml(stripMarkerEscapes(inner.innerHTML.replace(/\u200B/g, ''))))const grownH = Math.max(parseFloat(node.style.height) || 0, inner.scrollHeight)const el = this.store.doc.slides.find((slide) => slide.id === slideId)@@ -1614,7 +1622,7 @@ export class SlideCanvas {`td[data-r="${cell.r}"][data-c="${cell.c}"] .bento-cell-inner`)if (!inner || !id) returninner.contentEditable = 'false'- const html = sanitizeHtml(inner.innerHTML.replace(/\u200B/g, '').replace(/\\([*_~`-])/g, '$1'))+ const html = sanitizeHtml(stripMarkerEscapes(inner.innerHTML.replace(/\u200B/g, '')))const el = this.store.doc.slides.find((slide) => slide.id === slideId)?.elements.find((element) => element.id === id)diff --git a/slides/src/editor/markdown.ts b/slides/src/editor/markdown.tsindex 8690662e..8d5c4133 100644--- a/slides/src/editor/markdown.ts+++ b/slides/src/editor/markdown.ts@@ -147,16 +147,28 @@ function placeCaret(node: Node, offset: number) {const escapeHtml = (s: string) =>s.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')+/** A formula on one line, in any of the four delimiters the renderer reads+ * (maths/delimiters.ts). Markdown stays out of it: `\\_` is LaTeX's literal+ * underscore and `a^*` is a starred superscript, not an escape or emphasis. */+const FORMULA = /(\$\$[^$\n]+?\$\$|(?<!\\)\\\([^\n]+?\\\)|(?<!\\)\\\[[^\n]+?\\\]|(?<![\\$])\$\S(?:[^$\n]*?\S)?\$(?!\d))/++/** Drop the backslash from escaped markdown markers (`\\*x\\*` → `*x*`) —+ * outside formulas only (#540). */+export function stripMarkerEscapes(s: string): string {+ return s.split(FORMULA).map((part, i) => (i % 2 ? part : part.replace(/\\([*_~`-])/g, '$1'))).join('')+}+/** Pasted plain text → the inline-HTML subset (bold/italic/strike/code/bullets/<br>).* Backslash escapes markers: \*x\* pastes as literal *x*. */export function markdownToHtml(text: string): string {// park escaped markers in the private-use area so patterns can't see themconst PARK = ''const parked: string[] = []- const withParked = text.replace(/\\([*_~`-])/g, (_, c: string) => {- parked.push(c)- return PARK + (parked.length - 1) + PARK- })+ const park = (c: string) => PARK + (parked.push(c) - 1) + PARK+ // formulas first, whole and escaped, so no marker rule reaches inside one+ const withParked = text.split(FORMULA)+ .map((part, i) => (i % 2 ? park(escapeHtml(part)) : part.replace(/\\([*_~`-])/g, (_, c: string) => park(c))))+ .join('')const out = withParked.split('\n').map((line) => {diff --git a/slides/src/i18n/de.ts b/slides/src/i18n/de.tsindex fa7f487a..92c01cda 100644--- a/slides/src/i18n/de.ts+++ b/slides/src/i18n/de.ts@@ -943,4 +943,6 @@ export const de: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} Bilder werden noch hochgeladen; sie folgen.","1 picture still uploading…": "1 Bild wird noch hochgeladen…","{n} pictures still uploading…": "{n} Bilder werden noch hochgeladen…",+ "Not rendered: {what}": "Nicht gerendert: {what}",+ "no space just inside the $ signs": "kein Leerzeichen direkt innerhalb der $-Zeichen",}diff --git a/slides/src/i18n/es.ts b/slides/src/i18n/es.tsindex 5ba25198..4700b450 100644--- a/slides/src/i18n/es.ts+++ b/slides/src/i18n/es.ts@@ -943,4 +943,6 @@ export const es: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} imágenes todavía se están subiendo; llegarán después.","1 picture still uploading…": "1 imagen subiéndose…","{n} pictures still uploading…": "{n} imágenes subiéndose…",+ "Not rendered: {what}": "Sin representar: {what}",+ "no space just inside the $ signs": "sin espacio justo dentro de los signos $",}diff --git a/slides/src/i18n/fr.ts b/slides/src/i18n/fr.tsindex 35ea8df5..0ba60f36 100644--- a/slides/src/i18n/fr.ts+++ b/slides/src/i18n/fr.ts@@ -943,4 +943,6 @@ export const fr: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} images sont encore en cours d’envoi ; elles suivront.","1 picture still uploading…": "1 image en cours d’envoi…","{n} pictures still uploading…": "{n} images en cours d’envoi…",+ "Not rendered: {what}": "Non rendu : {what}",+ "no space just inside the $ signs": "pas d’espace juste à l’intérieur des signes $",}diff --git a/slides/src/i18n/it.ts b/slides/src/i18n/it.tsindex 22149874..048234e2 100644--- a/slides/src/i18n/it.ts+++ b/slides/src/i18n/it.ts@@ -943,4 +943,6 @@ export const it: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} immagini sono ancora in caricamento; arriveranno.","1 picture still uploading…": "1 immagine in caricamento…","{n} pictures still uploading…": "{n} immagini in caricamento…",+ "Not rendered: {what}": "Non visualizzata: {what}",+ "no space just inside the $ signs": "nessuno spazio subito dentro i segni $",}diff --git a/slides/src/i18n/ja.ts b/slides/src/i18n/ja.tsindex 3980970f..090992df 100644--- a/slides/src/i18n/ja.ts+++ b/slides/src/i18n/ja.ts@@ -943,4 +943,6 @@ export const ja: Catalog = {"{n} pictures are still uploading; they will follow.": "画像{n}枚がまだアップロード中です。あとで届きます。","1 picture still uploading…": "画像1枚をアップロード中…","{n} pictures still uploading…": "画像{n}枚をアップロード中…",+ "Not rendered: {what}": "表示できません: {what}",+ "no space just inside the $ signs": "$ 記号のすぐ内側に空白を入れないでください",}diff --git a/slides/src/i18n/packed.ts b/slides/src/i18n/packed.tsindex 8e6ea8a6..6bee08d7 100644--- a/slides/src/i18n/packed.ts+++ b/slides/src/i18n/packed.ts@@ -949,4 +949,6 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {"{n} pictures are still uploading; they will follow.": ["画像{n}枚がまだアップロード中です。あとで届きます。","还有 {n} 张图片正在上传;稍后送达。","還有 {n} 張圖片正在上傳;稍後送達。","{n} imágenes todavía se están subiendo; llegarán después.","{n} images sont encore en cours d’envoi ; elles suivront.","{n} Bilder werden noch hochgeladen; sie folgen.","{n} immagini sono ancora in caricamento; arriveranno.","{n} imagens ainda estão a ser enviadas; chegarão a seguir."],"1 picture still uploading…": ["画像1枚をアップロード中…","1 张图片上传中…","1 張圖片上傳中…","1 imagen subiéndose…","1 image en cours d’envoi…","1 Bild wird noch hochgeladen…","1 immagine in caricamento…","1 imagem a enviar…"],"{n} pictures still uploading…": ["画像{n}枚をアップロード中…","{n} 张图片上传中…","{n} 張圖片上傳中…","{n} imágenes subiéndose…","{n} images en cours d’envoi…","{n} Bilder werden noch hochgeladen…","{n} immagini in caricamento…","{n} imagens a enviar…"],+ "Not rendered: {what}": ["表示できません: {what}","未能渲染:{what}","未能呈現:{what}","Sin representar: {what}","Non rendu : {what}","Nicht gerendert: {what}","Non visualizzata: {what}","Não renderizada: {what}"],+ "no space just inside the $ signs": ["$ 記号のすぐ内側に空白を入れないでください","$ 符号内侧不要紧挨空格","$ 符號內側不要緊貼空格","sin espacio justo dentro de los signos $","pas d’espace juste à l’intérieur des signes $","kein Leerzeichen direkt innerhalb der $-Zeichen","nessuno spazio subito dentro i segni $","sem espaço logo dentro dos sinais $"],}diff --git a/slides/src/i18n/packs/ar.ts b/slides/src/i18n/packs/ar.tsindex 507a2f2b..25195a67 100644--- a/slides/src/i18n/packs/ar.ts+++ b/slides/src/i18n/packs/ar.ts@@ -959,4 +959,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "لا تزال {n} صور قيد الرفع؛ ستصل لاحقًا.","1 picture still uploading…": "صورة واحدة قيد الرفع…","{n} pictures still uploading…": "{n} صور قيد الرفع…",+ "Not rendered: {what}": "لم يُعرَض: {what}",+ "no space just inside the $ signs": "بدون مسافة مباشرة داخل علامتي $",}diff --git a/slides/src/i18n/packs/bn.ts b/slides/src/i18n/packs/bn.tsindex 2438c13a..2bbc4dd7 100644--- a/slides/src/i18n/packs/bn.ts+++ b/slides/src/i18n/packs/bn.ts@@ -962,4 +962,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n}টি ছবি এখনও আপলোড হচ্ছে; পরে পৌঁছাবে।","1 picture still uploading…": "১টি ছবি আপলোড হচ্ছে…","{n} pictures still uploading…": "{n}টি ছবি আপলোড হচ্ছে…",+ "Not rendered: {what}": "রেন্ডার হয়নি: {what}",+ "no space just inside the $ signs": "$ চিহ্নের ঠিক ভিতরে কোনো স্পেস নয়",}diff --git a/slides/src/i18n/packs/da.ts b/slides/src/i18n/packs/da.tsindex af6a1bc4..b10853d1 100644--- a/slides/src/i18n/packs/da.ts+++ b/slides/src/i18n/packs/da.ts@@ -951,4 +951,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} billeder uploades stadig; de følger.","1 picture still uploading…": "1 billede uploades…","{n} pictures still uploading…": "{n} billeder uploades…",+ "Not rendered: {what}": "Ikke gengivet: {what}",+ "no space just inside the $ signs": "intet mellemrum lige inden for $-tegnene",}diff --git a/slides/src/i18n/packs/fa.ts b/slides/src/i18n/packs/fa.tsindex 78ee54d4..bde3fee0 100644--- a/slides/src/i18n/packs/fa.ts+++ b/slides/src/i18n/packs/fa.ts@@ -955,4 +955,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} تصویر هنوز در حال بارگذاری است؛ بعداً میرسند.","1 picture still uploading…": "۱ تصویر در حال بارگذاری…","{n} pictures still uploading…": "{n} تصویر در حال بارگذاری…",+ "Not rendered: {what}": "نمایش داده نشد: {what}",+ "no space just inside the $ signs": "بدون فاصله درست داخل علامتهای $",}diff --git a/slides/src/i18n/packs/fi.ts b/slides/src/i18n/packs/fi.tsindex 66e82e05..1d496f02 100644--- a/slides/src/i18n/packs/fi.ts+++ b/slides/src/i18n/packs/fi.ts@@ -956,4 +956,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} kuvaa latautuu vielä; ne seuraavat perässä.","1 picture still uploading…": "1 kuva latautuu…","{n} pictures still uploading…": "{n} kuvaa latautuu…",+ "Not rendered: {what}": "Ei piirretty: {what}",+ "no space just inside the $ signs": "ei välilyöntiä heti $-merkkien sisäpuolelle",}diff --git a/slides/src/i18n/packs/fil.ts b/slides/src/i18n/packs/fil.tsindex a8479ff8..0f3b6614 100644--- a/slides/src/i18n/packs/fil.ts+++ b/slides/src/i18n/packs/fil.ts@@ -968,4 +968,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} larawan ang ina-upload pa; susunod ang mga ito.","1 picture still uploading…": "1 larawan ina-upload…","{n} pictures still uploading…": "{n} larawan ina-upload…",+ "Not rendered: {what}": "Hindi na-render: {what}",+ "no space just inside the $ signs": "walang espasyo agad sa loob ng mga $",}diff --git a/slides/src/i18n/packs/he.ts b/slides/src/i18n/packs/he.tsindex 0451e46f..81a15743 100644--- a/slides/src/i18n/packs/he.ts+++ b/slides/src/i18n/packs/he.ts@@ -952,4 +952,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} תמונות עדיין מועלות; הן יגיעו.","1 picture still uploading…": "תמונה אחת מועלית…","{n} pictures still uploading…": "{n} תמונות מועלות…",+ "Not rendered: {what}": "לא הוצג: {what}",+ "no space just inside the $ signs": "ללא רווח מיד בתוך סימני ה־$",}diff --git a/slides/src/i18n/packs/hi.ts b/slides/src/i18n/packs/hi.tsindex d7da03d5..40f49ece 100644--- a/slides/src/i18n/packs/hi.ts+++ b/slides/src/i18n/packs/hi.ts@@ -959,4 +959,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} चित्र अभी अपलोड हो रहे हैं; वे बाद में आएँगे।","1 picture still uploading…": "1 चित्र अपलोड हो रहा है…","{n} pictures still uploading…": "{n} चित्र अपलोड हो रहे हैं…",+ "Not rendered: {what}": "रेंडर नहीं हुआ: {what}",+ "no space just inside the $ signs": "$ चिह्नों के ठीक अंदर कोई स्पेस नहीं",}diff --git a/slides/src/i18n/packs/id.ts b/slides/src/i18n/packs/id.tsindex a158a59c..a53ca092 100644--- a/slides/src/i18n/packs/id.ts+++ b/slides/src/i18n/packs/id.ts@@ -949,4 +949,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} gambar masih diunggah; akan menyusul.","1 picture still uploading…": "1 gambar diunggah…","{n} pictures still uploading…": "{n} gambar diunggah…",+ "Not rendered: {what}": "Tidak dirender: {what}",+ "no space just inside the $ signs": "tanpa spasi tepat di dalam tanda $",}diff --git a/slides/src/i18n/packs/ko.ts b/slides/src/i18n/packs/ko.tsindex a8a048b2..d2865fa1 100644--- a/slides/src/i18n/packs/ko.ts+++ b/slides/src/i18n/packs/ko.ts@@ -943,4 +943,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "그림 {n}개가 아직 업로드 중입니다. 곧 도착합니다.","1 picture still uploading…": "그림 1개 업로드 중…","{n} pictures still uploading…": "그림 {n}개 업로드 중…",+ "Not rendered: {what}": "렌더링되지 않음: {what}",+ "no space just inside the $ signs": "$ 기호 바로 안쪽에 공백을 두지 마세요",}diff --git a/slides/src/i18n/packs/ms.ts b/slides/src/i18n/packs/ms.tsindex 3654e62c..c5bb4fc9 100644--- a/slides/src/i18n/packs/ms.ts+++ b/slides/src/i18n/packs/ms.ts@@ -952,4 +952,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} gambar masih dimuat naik; ia akan menyusul.","1 picture still uploading…": "1 gambar dimuat naik…","{n} pictures still uploading…": "{n} gambar dimuat naik…",+ "Not rendered: {what}": "Tidak dipaparkan: {what}",+ "no space just inside the $ signs": "tiada ruang betul-betul di dalam tanda $",}diff --git a/slides/src/i18n/packs/nb.ts b/slides/src/i18n/packs/nb.tsindex 76e7ac3b..b37f5ab0 100644--- a/slides/src/i18n/packs/nb.ts+++ b/slides/src/i18n/packs/nb.ts@@ -953,4 +953,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} bilder lastes fortsatt opp; de kommer etter.","1 picture still uploading…": "1 bilde lastes opp…","{n} pictures still uploading…": "{n} bilder lastes opp…",+ "Not rendered: {what}": "Ikke gjengitt: {what}",+ "no space just inside the $ signs": "ingen mellomrom rett innenfor $-tegnene",}diff --git a/slides/src/i18n/packs/nl.ts b/slides/src/i18n/packs/nl.tsindex eaf8b418..e8ec363b 100644--- a/slides/src/i18n/packs/nl.ts+++ b/slides/src/i18n/packs/nl.ts@@ -947,4 +947,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} afbeeldingen worden nog geüpload; die volgen.","1 picture still uploading…": "1 afbeelding wordt geüpload…","{n} pictures still uploading…": "{n} afbeeldingen worden geüpload…",+ "Not rendered: {what}": "Niet weergegeven: {what}",+ "no space just inside the $ signs": "geen spatie direct binnen de $-tekens",}diff --git a/slides/src/i18n/packs/pl.ts b/slides/src/i18n/packs/pl.tsindex bb906b6d..940f7384 100644--- a/slides/src/i18n/packs/pl.ts+++ b/slides/src/i18n/packs/pl.ts@@ -950,4 +950,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} obrazów wciąż się przesyła; dotrą później.","1 picture still uploading…": "1 obraz przesyłany…","{n} pictures still uploading…": "{n} obrazów przesyłanych…",+ "Not rendered: {what}": "Nie wyrenderowano: {what}",+ "no space just inside the $ signs": "bez spacji tuż wewnątrz znaków $",}diff --git a/slides/src/i18n/packs/ru.ts b/slides/src/i18n/packs/ru.tsindex 7cc050af..ef9c32c6 100644--- a/slides/src/i18n/packs/ru.ts+++ b/slides/src/i18n/packs/ru.ts@@ -951,4 +951,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} изображений ещё загружаются; они придут позже.","1 picture still uploading…": "1 изображение загружается…","{n} pictures still uploading…": "{n} изображений загружаются…",+ "Not rendered: {what}": "Не отображено: {what}",+ "no space just inside the $ signs": "без пробела сразу внутри знаков $",}diff --git a/slides/src/i18n/packs/sv.ts b/slides/src/i18n/packs/sv.tsindex 99dd9a64..cb2d6132 100644--- a/slides/src/i18n/packs/sv.ts+++ b/slides/src/i18n/packs/sv.ts@@ -948,4 +948,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} bilder laddas fortfarande upp; de kommer.","1 picture still uploading…": "1 bild laddas upp…","{n} pictures still uploading…": "{n} bilder laddas upp…",+ "Not rendered: {what}": "Inte återgiven: {what}",+ "no space just inside the $ signs": "inget mellanslag direkt innanför $-tecknen",}diff --git a/slides/src/i18n/packs/th.ts b/slides/src/i18n/packs/th.tsindex 45276659..826ed2c7 100644--- a/slides/src/i18n/packs/th.ts+++ b/slides/src/i18n/packs/th.ts@@ -953,4 +953,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "รูปภาพ {n} รูปยังอัปโหลดอยู่ จะตามมาภายหลัง","1 picture still uploading…": "กำลังอัปโหลดรูปภาพ 1 รูป…","{n} pictures still uploading…": "กำลังอัปโหลดรูปภาพ {n} รูป…",+ "Not rendered: {what}": "แสดงผลไม่ได้: {what}",+ "no space just inside the $ signs": "ห้ามเว้นวรรคชิดด้านในเครื่องหมาย $",}diff --git a/slides/src/i18n/packs/tk.ts b/slides/src/i18n/packs/tk.tsindex b1fdb8df..6016ea3e 100644--- a/slides/src/i18n/packs/tk.ts+++ b/slides/src/i18n/packs/tk.ts@@ -976,4 +976,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} surat henizem ýüklenýär; soňra geler.","1 picture still uploading…": "1 surat ýüklenýär…","{n} pictures still uploading…": "{n} surat ýüklenýär…",+ "Not rendered: {what}": "Görkezilmedi: {what}",+ "no space just inside the $ signs": "$ belgileriň edil içinde boşluk bolmaly däl",}diff --git a/slides/src/i18n/packs/tr.ts b/slides/src/i18n/packs/tr.tsindex b7e2654e..1d9c7eba 100644--- a/slides/src/i18n/packs/tr.ts+++ b/slides/src/i18n/packs/tr.ts@@ -950,4 +950,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} resim hâlâ yükleniyor; ardından gelecek.","1 picture still uploading…": "1 resim yükleniyor…","{n} pictures still uploading…": "{n} resim yükleniyor…",+ "Not rendered: {what}": "Görüntülenmedi: {what}",+ "no space just inside the $ signs": "$ işaretlerinin hemen içinde boşluk olmasın",}diff --git a/slides/src/i18n/packs/uk.ts b/slides/src/i18n/packs/uk.tsindex d17a363c..21bd1e0f 100644--- a/slides/src/i18n/packs/uk.ts+++ b/slides/src/i18n/packs/uk.ts@@ -959,4 +959,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} зображень ще завантажуються; вони надійдуть пізніше.","1 picture still uploading…": "1 зображення завантажується…","{n} pictures still uploading…": "{n} зображень завантажуються…",+ "Not rendered: {what}": "Не відображено: {what}",+ "no space just inside the $ signs": "без пробілу одразу всередині знаків $",}diff --git a/slides/src/i18n/packs/ur.ts b/slides/src/i18n/packs/ur.tsindex 58bf5b48..58356a0e 100644--- a/slides/src/i18n/packs/ur.ts+++ b/slides/src/i18n/packs/ur.ts@@ -969,4 +969,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} تصاویر ابھی اپ لوڈ ہو رہی ہیں؛ بعد میں آئیں گی۔","1 picture still uploading…": "1 تصویر اپ لوڈ ہو رہی ہے…","{n} pictures still uploading…": "{n} تصاویر اپ لوڈ ہو رہی ہیں…",+ "Not rendered: {what}": "رینڈر نہیں ہوا: {what}",+ "no space just inside the $ signs": "$ علامتوں کے بالکل اندر کوئی خالی جگہ نہیں",}diff --git a/slides/src/i18n/packs/vi.ts b/slides/src/i18n/packs/vi.tsindex eb732f6e..515ed968 100644--- a/slides/src/i18n/packs/vi.ts+++ b/slides/src/i18n/packs/vi.ts@@ -949,4 +949,6 @@ export const strings: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} hình vẫn đang tải lên; sẽ đến sau.","1 picture still uploading…": "1 hình đang tải lên…","{n} pictures still uploading…": "{n} hình đang tải lên…",+ "Not rendered: {what}": "Không hiển thị được: {what}",+ "no space just inside the $ signs": "không có dấu cách ngay bên trong cặp dấu $",}diff --git a/slides/src/i18n/pt.ts b/slides/src/i18n/pt.tsindex b5090736..baa3bfc7 100644--- a/slides/src/i18n/pt.ts+++ b/slides/src/i18n/pt.ts@@ -941,4 +941,6 @@ export const pt: Catalog = {"{n} pictures are still uploading; they will follow.": "{n} imagens ainda estão a ser enviadas; chegarão a seguir.","1 picture still uploading…": "1 imagem a enviar…","{n} pictures still uploading…": "{n} imagens a enviar…",+ "Not rendered: {what}": "Não renderizada: {what}",+ "no space just inside the $ signs": "sem espaço logo dentro dos sinais $",}diff --git a/slides/src/i18n/zh-Hans.ts b/slides/src/i18n/zh-Hans.tsindex 5a33462c..6514fc79 100644--- a/slides/src/i18n/zh-Hans.ts+++ b/slides/src/i18n/zh-Hans.ts@@ -943,4 +943,6 @@ export const zhHans: Catalog = {"{n} pictures are still uploading; they will follow.": "还有 {n} 张图片正在上传;稍后送达。","1 picture still uploading…": "1 张图片上传中…","{n} pictures still uploading…": "{n} 张图片上传中…",+ "Not rendered: {what}": "未能渲染:{what}",+ "no space just inside the $ signs": "$ 符号内侧不要紧挨空格",}diff --git a/slides/src/i18n/zh-Hant.ts b/slides/src/i18n/zh-Hant.tsindex 914109d7..b1797857 100644--- a/slides/src/i18n/zh-Hant.ts+++ b/slides/src/i18n/zh-Hant.ts@@ -943,4 +943,6 @@ export const zhHant: Catalog = {"{n} pictures are still uploading; they will follow.": "還有 {n} 張圖片正在上傳;稍後送達。","1 picture still uploading…": "1 張圖片上傳中…","{n} pictures still uploading…": "{n} 張圖片上傳中…",+ "Not rendered: {what}": "未能呈現:{what}",+ "no space just inside the $ signs": "$ 符號內側不要緊貼空格",}diff --git a/slides/src/maths/ast.ts b/slides/src/maths/ast.tsindex 78ad7d79..0119780f 100644--- a/slides/src/maths/ast.ts+++ b/slides/src/maths/ast.ts@@ -14,7 +14,7 @@export type MNode =| { k: 'row'; c: MNode[] }/** an identifier (mi), number (mn) or operator (mo) */- | { k: 'sym'; cls: 'i' | 'n' | 'o'; t: string; /** upright multi-letter (sin, lim) */ fn?: boolean; /** stretchy fence/accent op */ stretchy?: boolean; /** \mathrm-style upright single letter */ up?: boolean; /** big operator (sum) */ big?: boolean; /** \big family: minsize in em */ size?: number; /** explicit lspace/rspace (\mid) */ pad?: string; /** render-time: operator after an operator */ prefix?: boolean }+ | { k: 'sym'; cls: 'i' | 'n' | 'o'; t: string; /** upright multi-letter (sin, lim) */ fn?: boolean; /** stretchy fence/accent op */ stretchy?: boolean; /** \mathrm-style upright single letter */ up?: boolean; /** big operator (sum) */ big?: boolean; /** \big family: minsize in em */ size?: number; /** explicit lspace/rspace (\mid) */ pad?: string; /** a different rspace (\colon) */ rpad?: string; /** render-time: operator after an operator */ prefix?: boolean; /** \operatorname*: limits under/over in display mode */ limfn?: boolean }| { k: 'text'; t: string }| { k: 'space'; em: number }| { k: 'frac'; n: MNode; d: MNode; /** no bar (binom, atop) */ nobar?: boolean; /** \dfrac/\tfrac */ display?: boolean }@@ -25,6 +25,9 @@ export type MNode =| { k: 'fence'; l: string; r: string; c: MNode; /** minsize multiplier for \big family */ size?: number; /** \left…\right: say stretchy out loud (plain parens stretch by the operator dictionary anyway) */ explicit?: boolean }| { k: 'table'; rows: MNode[][]; l?: string; r?: string; /** column aligns, e.g. 'rl' for align */ align?: string; /** row lines */ lines?: boolean }| { k: 'accent'; b: MNode; a: string; under?: boolean; stretchy?: boolean }+ /** \xrightarrow[under]{over} and family: a stretchy arrow with labels+ * (printed the way Temml spells it — the labels padded, a 3.5em minimum) */+ | { k: 'xarrow'; a: string; over?: MNode; under?: MNode }/** font/colour/box wrapper */| { k: 'style'; c: MNode; font?: Font; color?: string; box?: boolean; /** \cancel */ cancel?: boolean }diff --git a/slides/src/maths/delimiters.ts b/slides/src/maths/delimiters.tsnew file mode 100644index 00000000..c72ed799--- /dev/null+++ b/slides/src/maths/delimiters.ts@@ -0,0 +1,154 @@+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento authors+/**+ * Finding the formulas in a text element's HTML. DOM-free — the caller+ * (render.ts) passes the renderer — so scripts/test-slides-math-delims.ts+ * drives this exact code.+ *+ * FOUR DELIMITERS. `$$…$$` and `\[…\]` are display; `$…$` and `\(…\)` are+ * inline. The backslash pair is what ChatGPT, Claude and Markdown emit, so a+ * pasted formula used to show raw (#540). An escaped opener is literal:+ * `\$` shows a dollar, `\\(` and `\\[` show `\(` and `\[`.+ *+ * TEXT RUNS ONLY (#465). The input is sanitized HTML and a `$` can sit inside+ * an attribute — `<a href="https://x.example/$a$b">`. So the HTML is split on+ * tags and each text run is searched on its own: a formula never enters or+ * spans a tag. ONE EXCEPTION, for display formulas: pressing Enter in a text+ * box puts `<br>` or `<div>` between the lines, and a `$$ … $$` typed over+ * several lines used to stay raw. A display formula may span LINE-BREAK tags+ * — `<br>`, `<div>`, `</div>` (or `<p>`, `</p>`, never both kinds in one+ * span) — and nothing else: the lines are joined, rendered as one, and the+ * whole span is replaced. The opens and closes it swallowed are put back+ * around the formula (opens before, closes after), so the markup stays+ * balanced whatever the lines looked like.+ *+ * The inline `$` rule stays fussy so prose survives: no whitespace just+ * inside the delimiters, no digit straight after the closer ("it costs $5 and+ * $10" is prose). `$ x^2 $` stays prose by design; in the editor it gets a+ * hint instead (below).+ *+ * HINTS (editor only). When `hint` is passed, a formula-shaped run that did+ * NOT render is wrapped in a span the editor styles with a dotted underline+ * and a title naming why — the first unknown command, or "no spaces just+ * inside the $ signs". Thumbnails, present, print and the file-manager+ * preview never pass it, and nothing here reaches the document: the model+ * keeps the author's text.+ */++export type RenderFn = (src: string, display: boolean) => string | null+/** why `src` did not render (the editor's hint title), or null for no hint */+export type HintFn = (src: string, display: boolean, spaced?: boolean) => string | null++/** placeholders for rendered MathML while the other rules run, so no rule+ * can see inside a formula already rendered (an `<mi>$</mi>` pairing with a+ * later `$` would be the bug) */+const HOLD = ''+const holdRe = /(\d+)/g++/** a line-break tag a display formula may span: <br>, <div>, </div>, <p>, </p> */+const BREAK = /^<(?:br\s*\/?|\/?(div|p))>$/i++const esc = (s: string) => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')++export function resolveMathHtml(html: string, render: RenderFn, hint?: HintFn): string {+ if (html.indexOf('$') < 0 && html.indexOf('\\(') < 0 && html.indexOf('\\[') < 0) return html+ const held: string[] = []+ const hold = (s: string) => `${HOLD}${held.push(s) - 1}${HOLD}`+ const parts = html.split(/(<[^>]*>)/) // even = text, odd = tag+ spanDisplay(parts, render, hold)+ const out = parts.map((p, i) => (i % 2 ? p : resolveRun(p, render, hold, hint))).join('')+ return out.replace(holdRe, (_m, n: string) => held[Number(n)])+}++/** the unescaped display opener left open at the end of a text run, if any */+function openDisplay(text: string): { at: number; kind: '$$' | '\\[' } | null {+ // walk the run: complete $$…$$ and \[…\] pairs close themselves+ let open: { at: number; kind: '$$' | '\\[' } | null = null+ for (let i = 0; i < text.length; i++) {+ if (text[i] === '\\' && text[i + 1] === '\\') { i++; continue } // \\ is an escaped backslash+ if (text[i] === '\\' && text[i + 1] === '$') { i++; continue }+ if (!open) {+ if (text.startsWith('$$', i)) { open = { at: i, kind: '$$' }; i++ }+ else if (text.startsWith('\\[', i)) { open = { at: i, kind: '\\[' }; i++ }+ } else if (open.kind === '$$' && text.startsWith('$$', i)) { open = null; i++ }+ else if (open.kind === '\\[' && text.startsWith('\\]', i)) { open = null; i++ }+ }+ return open+}++/** where the display formula opened in an earlier run closes in this one */+function closeDisplay(text: string, kind: '$$' | '\\['): number {+ for (let i = 0; i < text.length; i++) {+ if (text[i] === '\\' && (text[i + 1] === '\\' || text[i + 1] === '$')) { i++; continue }+ if (kind === '$$' ? text.startsWith('$$', i) : text.startsWith('\\]', i)) return i+ if (kind === '\\[' && text.startsWith('\\[', i)) return -1 // a second opener: not ours+ }+ return -1+}++const MAX_SPAN = 40 // parts: twenty lines is a formula, more is a document++/** Display formulas that span line-break tags, rendered in place. */+function spanDisplay(parts: string[], render: RenderFn, hold: (s: string) => string) {+ for (let i = 0; i < parts.length; i += 2) {+ const open = openDisplay(parts[i])+ if (!open) continue+ let src = parts[i].slice(open.at + 2)+ const tags: string[] = []+ const kinds = new Set<string>()+ for (let k = i + 1; k < parts.length && k - i <= MAX_SPAN; k += 2) {+ const m = BREAK.exec(parts[k])+ if (!m) break // any other tag: a formula never crosses it+ if (m[1]) kinds.add(m[1].toLowerCase())+ if (kinds.size > 1) break+ tags.push(parts[k])+ const next = parts[k + 1] ?? ''+ const close = closeDisplay(next, open.kind)+ if (close < 0) { src += '\n' + next; continue }+ const ml = render(src + '\n' + next.slice(0, close), true)+ if (!ml) break+ const opens = tags.filter((t) => /^<(div|p)>$/i.test(t)).join('')+ const closes = tags.filter((t) => /^<\/(div|p)>$/i.test(t)).join('')+ // before the opener stays text; the formula, with the tags it swallowed+ // balanced around it, is held; after the closer continues as text+ parts[i] = parts[i].slice(0, open.at) + hold(opens + ml + closes)+ parts.splice(i + 1, k + 1 - i, '', next.slice(close + 2))+ break // the loop visits the remainder (now i + 2) next+ }+ }+}++/** looks like maths someone meant: a command, a script */+const MATHY = /[\\^_]/++/** One text run: $$…$$ and \[…\] display, then \(…\) and $…$ inline. */+function resolveRun(text: string, render: RenderFn, hold: (s: string) => string, hint?: HintFn): string {+ if (text.indexOf('$') < 0 && text.indexOf('\\(') < 0 && text.indexOf('\\[') < 0) return text+ // a marked miss is held whole, so no later rule pairs a dollar inside it+ const mark = (raw: string, why: string | null) =>+ why ? hold(`<span class="bento-math-miss" title="${esc(why)}">${unescapeDelims(raw)}</span>`) : raw+ // `sure`: the delimiters alone say this was meant as maths. A failed $…$+ // could be prose that happens to hold two dollars, so it is only marked+ // when it looks mathematical.+ const rule = (display: boolean, sure: boolean) => (m: string, pre: string, src: string) => {+ const ml = render(src, display)+ if (ml) return pre + hold(ml)+ const raw = m.slice(pre.length)+ return pre + (hint && (sure || MATHY.test(src)) ? mark(raw, hint(src, display)) : raw)+ }+ let out = text.replace(/(^|[^\\])\$\$([^$]+?)\$\$/g, rule(true, true))+ // lookbehind, not a consumed prefix, so \(a\)\(b\) back to back both match+ out = out.replace(/(?<!\\)()\\\[([\s\S]+?)\\\]/g, rule(true, true))+ out = out.replace(/(?<!\\)()\\\(([\s\S]+?)\\\)/g, rule(false, true))+ out = out.replace(/(^|[^\\$])\$(\S(?:[^$\n]*?\S)?)\$(?!\d)/g, rule(false, false))+ // `$ x^2 $`: prose by design. What is left paired after the rules above+ // did not render; the maths-shaped ones with a space inside get a hint+ if (hint) {+ out = out.replace(/(^|[^\\$])\$([^$\n]+?)\$(?!\d)/g, (m, pre: string, src: string) =>+ /^\s|\s$/.test(src) && MATHY.test(src) ? pre + mark(m.slice(pre.length), hint(src, false, true)) : m)+ }+ return unescapeDelims(out)+}++/** the escapes have done their job: \$ is a dollar, \\( and \\[ are \( and \[ */+const unescapeDelims = (s: string) => s.replace(/\\\$/g, '$').replace(/\\\\([()[\]])/g, '\\$1')diff --git a/slides/src/maths/index.ts b/slides/src/maths/index.tsindex f86b4667..5b983ca7 100644--- a/slides/src/maths/index.ts+++ b/slides/src/maths/index.ts@@ -40,3 +40,19 @@ export function renderMath(src: string, opts: { display?: boolean; syntax?: Syntreturn null}}++/**+ * Why `src` does not render, or null when it does: the unknown command+ * (`\foo`) when that is the reason — the usual one — else the parser's own+ * message. For the editor's "Not rendered" hint; never shown in a document.+ */+export function mathError(src: string, opts: { display?: boolean; syntax?: Syntax } = {}): string | null {+ try {+ toMathML(parseMath(src, opts), !!opts.display)+ return null+ } catch (e) {+ const msg = e instanceof Error ? e.message : String(e)+ const unknown = /^unknown command (\\\S+)/.exec(msg)+ return unknown ? unknown[1] : msg+ }+}diff --git a/slides/src/maths/latex.ts b/slides/src/maths/latex.tsindex 2cdc5157..05e62b00 100644--- a/slides/src/maths/latex.ts+++ b/slides/src/maths/latex.ts@@ -9,7 +9,15 @@*/import { type MNode, type Font, row, mi, mn, mo, MathError, symNode } from './ast.ts'-import { byTex, FUNCTIONS, LIMIT_FUNCTIONS } from './symbols.ts'+import { byTex, FUNCTIONS, LIMIT_FUNCTIONS, styledChar } from './symbols.ts'++/** A node that is only letters (\rm Res, \mathrm{Res}) as its text, else null. */+function textOf(n: MNode): string | null {+ if (n.k === 'sym' && n.cls === 'i') return n.t+ if (n.k === 'style' && !n.color && !n.box && !n.cancel) return textOf(n.c)+ if (n.k === 'row') { const parts = n.c.map(textOf); return parts.every((p) => p !== null) && parts.length ? parts.join('') : null }+ return null+}type Tok = { t: 'cmd' | 'ch' | '{' | '}' | '^' | '_' | '&' | '\\\\' | 'ws'; v: string }@@ -39,12 +47,26 @@ function tokenize(src: string): Tok[] {const OPEN_FENCES: Record<string, string> = { '(': '(', '[': '[', '\\{': '{', '|': '|', '.': '', '\\langle': '⟨', '\\lfloor': '⌊', '\\lceil': '⌈', '\\|': '‖', '\\vert': '|', '\\Vert': '‖', '\\lbrace': '{', '\\lbrack': '[' }const CLOSE_FENCES: Record<string, string> = { ')': ')', ']': ']', '\\}': '}', '|': '|', '.': '', '\\rangle': '⟩', '\\rfloor': '⌋', '\\rceil': '⌉', '\\|': '‖', '\\vert': '|', '\\Vert': '‖', '\\rbrace': '}', '\\rbrack': ']' }const BIG: Record<string, number> = { big: 1.2, Big: 1.8, bigg: 2.4, Bigg: 3 }-const ACCENTS: Record<string, [string, boolean?]> = { hat: ['^'], widehat: ['^', true], tilde: ['~'], widetilde: ['~', true], bar: ['‾'], overline: ['‾', true], vec: ['→'], dot: ['˙'], ddot: ['¨'], acute: ['´'], grave: ['`'], breve: ['˘'], check: ['ˇ'], overrightarrow: ['→', true], overleftarrow: ['←', true] }+const ACCENTS: Record<string, [string, boolean?]> = { hat: ['^'], widehat: ['^', true], tilde: ['~'], widetilde: ['~', true], bar: ['‾'], overline: ['‾', true], vec: ['→'], dot: ['˙'], ddot: ['¨'], acute: ['´'], grave: ['`'], breve: ['˘'], check: ['ˇ'], overrightarrow: ['→', true], overleftarrow: ['←', true], mathring: ['˚'] }const UNDER: Record<string, string> = { underline: '_', underbrace: '⏟', underrightarrow: '→' }const OVER: Record<string, string> = { overbrace: '⏞' }const FONTS: Record<string, Font> = { mathbb: 'bb', mathcal: 'cal', mathscr: 'scr', mathfrak: 'frak', mathbf: 'bf', boldsymbol: 'bf', bm: 'bf', mathit: 'it', mathsf: 'sf', mathtt: 'tt', mathrm: 'rm', operatorname: 'rm', textbf: 'bf', textit: 'it' }-const SPACES: Record<string, number> = { ',': 0.1667, ':': 0.2222, ';': 0.2778, '!': -0.1667, quad: 1, qquad: 2, ' ': 0.25 }-const ENV_FENCES: Record<string, [string, string]> = { matrix: ['', ''], pmatrix: ['(', ')'], bmatrix: ['[', ']'], Bmatrix: ['{', '}'], vmatrix: ['|', '|'], Vmatrix: ['‖', '‖'], cases: ['{', ''], aligned: ['', ''], align: ['', ''], 'align*': ['', ''], gathered: ['', ''], gather: ['', ''], array: ['', ''], smallmatrix: ['', ''] }+const SPACES: Record<string, number> = { ',': 0.1667, ':': 0.2222, ';': 0.2778, '!': -0.1667, quad: 1, qquad: 2, ' ': 0.25, thinspace: 0.1667, medspace: 0.2222, thickspace: 0.2778, enspace: 0.5, negthinspace: -0.1667 }+const ENV_FENCES: Record<string, [string, string]> = { matrix: ['', ''], pmatrix: ['(', ')'], bmatrix: ['[', ']'], Bmatrix: ['{', '}'], vmatrix: ['|', '|'], Vmatrix: ['‖', '‖'], cases: ['{', ''], aligned: ['', ''], align: ['', ''], 'align*': ['', ''], gathered: ['', ''], gather: ['', ''], 'gather*': ['', ''], array: ['', ''], smallmatrix: ['', ''], split: ['', ''], multline: ['', ''], 'multline*': ['', ''], eqnarray: ['', ''], 'eqnarray*': ['', ''], equation: ['', ''], 'equation*': ['', ''], alignat: ['', ''], 'alignat*': ['', ''], alignedat: ['', ''] }+/** \xrightarrow and family: the arrow each draws */+const XARROWS: Record<string, string> = { xrightarrow: '→', xleftarrow: '←', xleftrightarrow: '↔', xRightarrow: '⇒', xLeftarrow: '⇐', xLeftrightarrow: '⇔', xmapsto: '↦', xhookrightarrow: '↪', xhookleftarrow: '↩', xtwoheadrightarrow: '↠', xtwoheadleftarrow: '↞', xlongequal: '=' }+/** the old font switches (\rm Res): the rest of the group in that font */+const SWITCHES: Record<string, Font> = { rm: 'rm', bf: 'bf', it: 'it', sf: 'sf', tt: 'tt', cal: 'cal' }+/** infix fractions: {a \over b}, {n \choose k}, {a \atop b} */+const INFIX = new Set(['over', 'choose', 'atop', 'brace', 'brack'])+/** a TeX dimension → em (the units a slide formula can mean; 10pt type) */+function dimEm(s: string): number {+ const m = /^\s*(-?[\d.]+)\s*(em|ex|pt|mu|px|mm|cm|in|bp|pc)?\s*$/.exec(s)+ if (!m) throw new MathError(`bad dimension ${s}`)+ const n = parseFloat(m[1])+ const per: Record<string, number> = { em: 1, ex: 0.431, pt: 0.1, mu: 1 / 18, px: 0.0625, mm: 0.2845, cm: 2.845, in: 7.227, bp: 0.1004, pc: 1.2 }+ return n * per[m[2] ?? 'em']+}class Parser {i = 0@@ -58,12 +80,41 @@ class Parser {next(): Tok { this.skipWs(); const t = this.toks[this.i++]; if (!t) throw new MathError('unexpected end'); return t }is(t: Tok['t'], v?: string): boolean { const p = this.peek(); return !!p && p.t === t && (v === undefined || p.v === v) }- /** A sequence up to a terminator the caller owns. */+ /** A sequence up to a terminator the caller owns. An infix fraction+ * (\over, \choose, \atop) splits the WHOLE sequence at itself. */parseRow(stop: (t: Tok) => boolean): MNode {const c: MNode[] = []- while (this.peek() && !stop(this.peek()!)) c.push(this.parseScripted())+ while (this.peek() && !stop(this.peek()!)) {+ const p = this.peek()!+ if (p.t === 'cmd' && INFIX.has(p.v)) {+ this.next()+ const n = row(c), d = this.parseRow(stop)+ if (p.v === 'over') return { k: 'frac', n, d }+ const f: MNode = { k: 'frac', n, d, nobar: true }+ if (p.v === 'atop') return f+ const [l, r] = p.v === 'choose' ? ['(', ')'] : p.v === 'brace' ? ['{', '}'] : ['[', ']']+ return { k: 'fence', l, r, c: f, explicit: true }+ }+ const n = this.parseScripted()+ // \notag, \vspace, \displaystyle: nothing to lay out, so no empty box+ if (!(n.k === 'row' && n.c.length === 0)) c.push(n)+ }return row(c)}+ /** A macro's argument: a {group}, or ONE token — \frac12 is 1 over 2,+ * where a bare 12 in a row is the number twelve. */+ parseArg(): MNode {+ const p = this.peek()+ if (!p) throw new MathError('missing argument')+ if (p.t === '{') return this.parseGroup()+ if (p.t === 'ch') { this.next(); return /[0-9]/.test(p.v) ? mn(p.v) : this.charAtomSingle(p.v) }+ return this.parseAtom()+ }+ private charAtomSingle(v: string): MNode {+ if (/[a-zA-Z]/.test(v)) return mi(v)+ if ('+-*/=<>,;:!?|.()[]'.includes(v)) return mo(v === '-' ? '−' : v === '*' ? '∗' : v)+ return mi(v)+ }parseGroup(): MNode {if (this.is('{')) {this.next()@@ -81,7 +132,7 @@ class Parser {// big operators take under/over limits in display mode — except the// integrals, which TeX (and Temml) keep at the sidelet limits = base.k === 'sym' && !!base.big && this.display && !/[∫∬∭∮]/.test(base.t)- if (base.k === 'sym' && base.fn && LIMIT_FUNCTIONS.includes(base.t)) limits = this.display+ if (base.k === 'sym' && base.fn && (LIMIT_FUNCTIONS.includes(base.t) || base.limfn)) limits = this.displayfor (;;) {if (this.is('cmd', 'limits')) { this.next(); limits = true; continue }if (this.is('cmd', 'nolimits')) { this.next(); limits = false; continue }@@ -134,8 +185,20 @@ class Parser {if (sym) return symNode(sym)if (FUNCTIONS.includes(name) || LIMIT_FUNCTIONS.includes(name)) return mi(name, { fn: true })if (name in SPACES) return { k: 'space', em: SPACES[name] }- if (name in FONTS) return this.font(FONTS[name], name === 'operatorname')- if (name in ACCENTS) { const [a, s] = ACCENTS[name]; return { k: 'accent', b: this.parseGroup(), a, stretchy: s } }+ if (name in FONTS) {+ // \operatorname*{argmax}: the star puts its scripts under/over in display+ if (name === 'operatorname' && this.is('ch', '*')) { this.next(); const n = this.font('rm', true); if (n.k === 'sym') n.limfn = true; return n }+ return this.font(FONTS[name], name === 'operatorname')+ }+ if (name in SWITCHES) return { k: 'style', c: this.parseRow((t) => t.t === '}'), font: SWITCHES[name] }+ if (name in XARROWS) {+ let under: MNode | undefined+ if (this.is('ch', '[')) { this.next(); under = this.parseRow((t) => t.t === 'ch' && t.v === ']'); this.next() }+ const over = this.parseArg()+ const empty = (n: MNode | undefined) => !n || (n.k === 'row' && n.c.length === 0)+ return { k: 'xarrow', a: XARROWS[name], over: empty(over) ? undefined : over, under: empty(under) ? undefined : under }+ }+ if (name in ACCENTS) { const [a, s] = ACCENTS[name]; return { k: 'accent', b: this.parseArg(), a, stretchy: s } }if (name in UNDER) { const b = this.parseGroup(); const node: MNode = { k: 'accent', b, a: UNDER[name], under: true, stretchy: true }; return this.braceLabel(node, name === 'underbrace', true) }if (name in OVER) { const b = this.parseGroup(); const node: MNode = { k: 'accent', b, a: OVER[name], stretchy: true }; return this.braceLabel(node, true, false) }if (name in BIG || /^[bB]igg?[lrm]$/.test(name)) {@@ -144,12 +207,61 @@ class Parser {return mo(d, { stretchy: true, size })}switch (name) {- case 'frac': case 'dfrac': case 'tfrac': return { k: 'frac', n: this.parseGroup(), d: this.parseGroup(), display: name === 'dfrac' ? true : name === 'tfrac' ? false : undefined }- case 'binom': case 'dbinom': case 'tbinom': return { k: 'fence', l: '(', r: ')', c: { k: 'frac', n: this.parseGroup(), d: this.parseGroup(), nobar: true }, explicit: true }+ case 'frac': case 'dfrac': case 'tfrac': return { k: 'frac', n: this.parseArg(), d: this.parseArg(), display: name === 'dfrac' ? true : name === 'tfrac' ? false : undefined }+ case 'cfrac': return { k: 'frac', n: this.parseArg(), d: this.parseArg(), display: true }+ case 'binom': case 'dbinom': case 'tbinom': return { k: 'fence', l: '(', r: ')', c: { k: 'frac', n: this.parseArg(), d: this.parseArg(), nobar: true }, explicit: true }+ case 'genfrac': {+ // \genfrac{left}{right}{thickness}{style}{num}{den}+ const fenceOf = (s: string, close: boolean) => { const t = s.trim(); if (!t) return ''; const tab = close ? CLOSE_FENCES : OPEN_FENCES; if (t in tab) return tab[t]; if (t in OPEN_FENCES) return OPEN_FENCES[t]; if (t in CLOSE_FENCES) return CLOSE_FENCES[t]; throw new MathError(`bad delimiter ${t}`) }+ const rawArg = () => { if (this.is('{')) { this.next(); let s = ''; while (!this.is('}')) { const t = this.next(); s += t.t === 'cmd' ? '\\' + t.v : t.v } this.next(); return s } return this.next().v }+ const l = fenceOf(rawArg(), false), r = fenceOf(rawArg(), true), thick = rawArg().trim(), st = rawArg().trim()+ const f: MNode = { k: 'frac', n: this.parseArg(), d: this.parseArg(), nobar: /^0(\.0*)?\s*[a-z]*$/.test(thick) || undefined, display: st === '0' ? true : st === '1' ? false : undefined }+ return l || r ? { k: 'fence', l, r, c: f, explicit: true } : f+ }case 'sqrt': {let idx: MNode | undefinedif (this.is('ch', '[')) { this.next(); idx = this.parseRow((t) => t.t === 'ch' && t.v === ']'); this.next() }- return { k: 'sqrt', b: this.parseGroup(), i: idx }+ return { k: 'sqrt', b: this.parseArg(), i: idx }+ }+ case 'middle': return mo(this.delim(), { stretchy: true, pad: '0.05em' })+ case 'colon': return mo(':', { pad: '0em', rpad: '0.1667em' })+ case 'bmod': return mo('mod', { pad: '0.2222em' })+ case 'pmod': case 'pod': case 'mod': {+ const arg = this.parseArg()+ const modWord = mi('mod', { fn: true })+ // an empty <mo> first, as Temml writes it: a line may break there+ if (name === 'mod') return row([mo(''), { k: 'space', em: 0.6667 }, modWord, { k: 'space', em: 0.3333 }, arg])+ return row([mo(''), { k: 'space', em: 0.4444 }, { k: 'fence', l: '(', r: ')', c: name === 'pmod' ? row([modWord, { k: 'space', em: 0.3333 }, arg]) : arg }])+ }+ case 'substack': {+ if (!this.is('{')) throw new MathError('\\substack needs a group')+ this.next()+ const rows: MNode[][] = [[this.parseRow((t) => t.t === '}' || t.t === '\\\\')]]+ while (this.is('\\\\')) { this.next(); rows.push([this.parseRow((t) => t.t === '}' || t.t === '\\\\')]) }+ if (!this.is('}')) throw new MathError('missing }')+ this.next()+ return { k: 'table', rows, align: 's' }+ }+ case 'mathbin': case 'mathrel': case 'mathord': case 'mathop': case 'mathopen': case 'mathclose': case 'mathpunct': {+ const g = this.parseArg()+ const flat = textOf(g)+ if (name === 'mathord') return g.k === 'sym' ? mi(g.t) : g+ if (name === 'mathop') return flat !== null ? mi(flat, { fn: true }) : g+ if (g.k !== 'sym') return g+ const pad = name === 'mathbin' ? '0.2222em' : name === 'mathrel' ? '0.2778em' : name === 'mathpunct' ? '0em' : undefined+ return mo(g.t, pad ? { pad, rpad: name === 'mathpunct' ? '0.1667em' : undefined } : {})+ }+ case 'emph': return { k: 'text', t: [...this.rawGroup()].map((c) => styledChar(c, 'it')).join('') }+ case 'hspace': { if (this.is('ch', '*')) this.next(); return { k: 'space', em: dimEm(this.rawGroup()) } }+ case 'mspace': case 'hskip': case 'kern': case 'mkern': case 'mskip': { const d = this.rawGroup(); return { k: 'space', em: dimEm(name.startsWith('m') && !/[a-z]{2}\s*$/.test(d) ? d + 'mu' : d) } }+ case 'vspace': { if (this.is('ch', '*')) this.next(); this.rawGroup(); return { k: 'row', c: [] } }+ case 'notag': case 'nonumber': case 'label': { if (name === 'label') this.rawGroup(); return { k: 'row', c: [] } }+ case 'tag': {+ // an equation label, set after the formula at a quad's distance;+ // \tag* without the parentheses+ const star = this.is('ch', '*'); if (star) this.next()+ const t = this.rawGroup()+ return row([{ k: 'space', em: 1 }, { k: 'text', t: star ? t : `(${t})` }])}case 'left': {const l = this.delim()@@ -229,7 +341,7 @@ class Parser {const name = this.rawGroup()const fences = ENV_FENCES[name]if (!fences) throw new MathError(`unknown environment ${name}`)- if (name === 'array') this.rawGroup() // column spec, ignored beyond alignment+ if (name === 'array' || name.startsWith('alignat')) this.rawGroup() // column spec / column count, ignored beyond alignmentconst rows: MNode[][] = [[]]const cur = () => rows[rows.length - 1]const cell = (): MNode => this.parseRow((t) => t.t === '&' || t.t === '\\\\' || (t.t === 'cmd' && t.v === 'end'))@@ -242,7 +354,10 @@ class Parser {}// a trailing \\ leaves an empty last rowif (rows.length > 1 && rows[rows.length - 1].length === 1 && rows[rows.length - 1][0].k === 'row' && (rows[rows.length - 1][0] as { c: MNode[] }).c.length === 0) rows.pop()- const align = name.startsWith('align') || name === 'aligned' ? 'rl' : name === 'cases' ? 'll' : 'c'+ const align = name.startsWith('align') || name === 'aligned' || name === 'split' || name.startsWith('eqnarray') ? 'rl'+ : name === 'cases' ? 'll' : name.startsWith('multline') || name.startsWith('gather') || name.startsWith('equation') ? 'd' : 'c'+ // equation: one line, no table around it+ if (name.startsWith('equation') && rows.length === 1 && rows[0].length === 1) return rows[0][0]return { k: 'table', rows, l: fences[0], r: fences[1], align }}}diff --git a/slides/src/maths/mathml.ts b/slides/src/maths/mathml.tsindex 83b62e39..3e991e03 100644--- a/slides/src/maths/mathml.ts+++ b/slides/src/maths/mathml.ts@@ -53,9 +53,9 @@ function print(n: MNode, font: Font | undefined): string {return font === 'rm' || n.up ? `<mi mathvariant="normal">${esc(t)}</mi>` : `<mi>${esc(t)}</mi>`}const attrs: string[] = []- if (n.pad !== undefined) attrs.push(` lspace="${n.pad}" rspace="${n.pad}"`)+ if (n.pad !== undefined) attrs.push(` lspace="${n.pad}" rspace="${n.rpad ?? n.pad}"`)if (n.prefix && !'([{)]}'.includes(n.t)) attrs.push(' form="prefix" stretchy="false"')- if (n.t === '|' && n.pad !== undefined) attrs.push(' stretchy="false"')+ if (n.t === '|' && n.pad !== undefined && !n.stretchy) attrs.push(' stretchy="false"')// a bare "(" in the middle of a row would be inferred INFIX by MathML// Core and spaced like a binary operator; TeX treats it as an opening// fence. Temml spells this out per paren; so do we.@@ -98,7 +98,7 @@ function print(n: MNode, font: Font | undefined): string {// cases: 1em before the condition column; aligned: none (the & carries// the relation's own spacing); matrices: Temml's absolute 5.9776ptconst pad = (i: number) => cols === 'll' ? `padding-left:${i === 0 ? '0' : '1'}em;padding-right:0em`- : cols === 'rl' ? 'padding-left:0em;padding-right:0em'+ : cols === 'rl' || cols === 's' || cols === 'd' ? 'padding-left:0em;padding-right:0em': `padding-left:${i === 0 ? '0em' : '5.9776pt'};padding-right:${i === ncol - 1 ? '0em' : '5.9776pt'}`// centred cells say nothing (the default); left/right say so the way// Temml's tml-left/tml-right classes would with its stylesheet@@ -109,9 +109,21 @@ function print(n: MNode, font: Font | undefined): string {// (2026-09-15): nothing moves on update. `al` still decides the padding.const body = n.rows.map((r) => `<mtr>${r.map((c, i) => `<mtd style="${pad(i)}">${print(c, font)}</mtd>`).join('')}</mtr>`).join('')// aligned/gather rows are display-style (Temml sets it on the table)- const table = `<mtable${cols === 'rl' ? ' displaystyle="true"' : ''}>${body}</mtable>`+ const table = `<mtable${cols === 'rl' || cols === 'd' ? ' displaystyle="true"' : ''}>${body}</mtable>`return n.l || n.r ? `<mrow><mo fence="true" form="prefix" stretchy="true">${esc(n.l ?? '')}</mo>${table}<mo fence="true" form="postfix" stretchy="true">${esc(n.r ?? '')}</mo></mrow>` : table}+ case 'xarrow': {+ // Temml's spelling, so a deck keeps its look: the arrow stretches under+ // a label padded 0.4286em a side, over a 3.5em minimum, a thick space+ // either side of the whole+ const lab = (x: MNode, under: boolean) => `<${under ? 'munder' : 'mover'}><mrow><mspace width="0.4286em"></mspace>${print(x, font)}<mspace width="0.4286em"></mspace></mrow><mspace width="3.5em"></mspace></${under ? 'munder' : 'mover'}>`+ const arrow = `<mo stretchy="true" lspace="0em" rspace="0em">${esc(n.a)}</mo>`+ const body = n.over && n.under ? `<munderover>${arrow}${lab(n.under, true)}${lab(n.over, false)}</munderover>`+ : n.under ? `<munder>${arrow}${lab(n.under, true)}</munder>`+ : n.over ? `<mover>${arrow}${lab(n.over, false)}</mover>`+ : `<mover>${arrow}<mspace width="3.5em"></mspace></mover>`+ return `<mrow><mspace width="0.2778em"></mspace>${body}<mspace width="0.2778em"></mspace></mrow>`+ }case 'accent': {// math-depth:0 keeps the accent glyph at full size inside scripts — the// same spelling Temml uses, so a deck looks the way it does todaydiff --git a/slides/src/maths/symbols.ts b/slides/src/maths/symbols.tsindex ec179fac..b79ce31d 100644--- a/slides/src/maths/symbols.ts+++ b/slides/src/maths/symbols.ts@@ -31,6 +31,7 @@ export const SYMBOLS: Sym[] = [T('cdot', 'dot.op', '⋅'), T('ast', 'ast', '∗'), T('star', 'star', '⋆'), T('circ', 'compose', '∘'),T('bullet', 'bullet', '∙'), T('cap', 'sect', '∩'), T('cup', 'union', '∪'), T('setminus', 'without', '∖'),T('oplus', 'plus.circle', '⊕'), T('otimes', 'times.circle', '⊗'), T('wedge', 'and', '∧'), T('vee', 'or', '∨'),+ T('land', 'and', '∧'), T('lor', 'or', '∨'), T('dagger', 'dagger', '†'), T('ddagger', 'dagger.double', '‡'), T('diamond', 'diamond.stroked.small', '⋄'),// relationsT('le', 'lt.eq', '≤'), T('leq', 'lt.eq', '≤'), T('ge', 'gt.eq', '≥'), T('geq', 'gt.eq', '≥'), T('ne', 'eq.not', '≠'), T('neq', 'eq.not', '≠'),T('approx', 'approx', '≈'), T('equiv', 'equiv', '≡'), T('sim', 'tilde.op', '∼'), T('simeq', 'tilde.eq', '≃'), T('cong', 'tilde.equiv', '≅'),@@ -38,19 +39,28 @@ export const SYMBOLS: Sym[] = [T('subset', 'subset', '⊂'), T('supset', 'supset', '⊃'), T('subseteq', 'subset.eq', '⊆'), T('supseteq', 'supset.eq', '⊇'),T('in', 'in', '∈'), T('notin', 'in.not', '∉'), T('ni', 'in.rev', '∋'), T('parallel', 'parallel', '∥'), T('perp', 'perp', '⟂'),T('mid', 'divides', '|'), T('models', 'models', '⊧'), T('vdash', 'tack.r', '⊢'),+ T('nmid', 'divides.not', '∤'), T('nparallel', 'parallel.not', '∦'),+ T('leqslant', 'lt.eq.slant', '⩽'), T('geqslant', 'gt.eq.slant', '⩾'), T('lesssim', 'lt.tilde', '≲'), T('gtrsim', 'gt.tilde', '≳'),+ T('nleq', 'lt.eq.not', '≰'), T('ngeq', 'gt.eq.not', '≱'), T('nless', 'lt.not', '≮'), T('ngtr', 'gt.not', '≯'), T('lneq', 'lt.neq', '⪇'), T('gneq', 'gt.neq', '⪈'),+ T('nsim', 'tilde.not', '≁'), T('ncong', 'tilde.equiv.not', '≇'),+ T('subsetneq', 'subset.neq', '⊊'), T('supsetneq', 'supset.neq', '⊋'), T('varsubsetneq', 'subset.neq', '⊊︀'), T('varsupsetneq', 'supset.neq', '⊋︀'),+ T('nsubseteq', 'subset.eq.not', '⊈'), T('nsupseteq', 'supset.eq.not', '⊉'),// arrowsT('to', 'arrow.r', '→'), T('rightarrow', 'arrow.r', '→'), T('leftarrow', 'arrow.l', '←'), T('leftrightarrow', 'arrow.l.r', '↔'),T('Rightarrow', 'arrow.r.double', '⇒'), T('Leftarrow', 'arrow.l.double', '⇐'), T('Leftrightarrow', 'arrow.l.r.double', '⇔'), T('iff', 'arrow.l.r.double.long', '⟺'),T('mapsto', 'arrow.r.bar', '↦'), T('longrightarrow', 'arrow.r.long', '⟶'), T('uparrow', 'arrow.t', '↑'), T('downarrow', 'arrow.b', '↓'),T('implies', 'arrow.r.double.long', '⟹'), T('hookrightarrow', 'arrow.r.hook', '↪'),+ T('gets', 'arrow.l', '←'),// logic & setsT('forall', 'forall', '∀', 'i'), T('exists', 'exists', '∃', 'i'), T('nexists', 'exists.not', '∄', 'i'), T('neg', 'not', '¬'), T('lnot', 'not', '¬'),T('emptyset', 'emptyset', '∅', 'i'), T('varnothing', 'nothing', '∅', 'i'), T('infty', 'infinity', '∞', 'i'), T('partial', 'diff', '∂', 'i'), T('nabla', 'nabla', '∇'),T('angle', 'angle', '∠'), T('triangle', 'triangle', '△'), T('hbar', 'planck.reduce', 'ℏ', 'i'), T('ell', 'ell', 'ℓ', 'i'),T('Re', 'Re', 'ℜ', 'i'), T('Im', 'Im', 'ℑ', 'i'), T('aleph', 'aleph', 'ℵ', 'i'), T('wp', 'wp', '℘', 'i'),T('degree', 'degree', '°'), T('prime', 'prime', '′'), T('therefore', 'therefore', '∴'), T('because', 'because', '∵'),+ T('top', 'top', '⊤', 'i'), T('bot', 'bot', '⊥', 'i'), T('square', 'square.stroked', '□', 'i'), T('Box', 'square.stroked', '□', 'i'), T('blacksquare', 'square.filled', '■', 'i'), T('checkmark', 'checkmark', '✓', 'i'),// dotsT('ldots', 'dots.h', '…'), T('cdots', 'dots.h.c', '⋯'), T('vdots', 'dots.v', '⋮'), T('ddots', 'dots.down', '⋱'), T('dots', 'dots', '…'),+ T('dotsc', 'dots.h', '…'), T('dotso', 'dots.h', '…'), T('dotsb', 'dots.h.c', '⋯'), T('dotsm', 'dots.h.c', '⋯'), T('dotsi', 'dots.h.c', '⋯'),// big operators (limits go under/over in display mode)T('sum', 'sum', '∑', 'big'), T('prod', 'product', '∏', 'big'), T('coprod', 'coproduct', '∐', 'big'),T('int', 'integral', '∫', 'big'), T('iint', 'integral.double', '∬', 'big'), T('iiint', 'integral.triple', '∭', 'big'), T('oint', 'integral.cont', '∮', 'big'),diff --git a/slides/src/render.ts b/slides/src/render.tsindex 64f8ec5b..772d34a5 100644--- a/slides/src/render.ts+++ b/slides/src/render.ts@@ -7,7 +7,8 @@ import { offlineEnabled, isRemoteUrl, remoteSrcBlocked } from '../../kernel/src/import type { BentoDoc, EmbedElement, ShapeElement, Slide, SlideElement, SvgElement, TableElement } from './model'import { morphKey, paginates, isWebUrl } from './model'import { chartSnapshotSvg } from './charts'-import { renderMath as mathsLite } from './maths/index.ts'+import { renderMath as mathsLite, mathError } from './maths/index.ts'+import { resolveMathHtml } from './maths/delimiters.ts'import { renderCodeInto } from './code'import { tipSpec, tipInsetPx, shortenPathEnds } from './tips'import { formatDate } from './datefmt'@@ -25,6 +26,11 @@ export interface RenderOpts {liveMedia?: boolean/** dynamic-field values ({{page}} etc.) for this slide; auto-filled by renderSlide */fields?: FieldContext+ /** EDITOR CANVAS only: mark a formula that did not render (dotted+ * underline + a title from this, given what went wrong — `\\foo`, or+ * "spaces" for `$ x^2 $`). Thumbnails, present, print and the static+ * preview never pass it, so the hint never leaves the editor. */+ mathHint?: (what: string) => string}/** Values dynamic field tokens resolve against, computed per slide. */@@ -569,33 +575,17 @@ function renderMath(src: string, display: boolean): string | null {return out}-export function resolveMath(html: string): string {- if (html.indexOf('$') < 0) return html- // TEXT SEGMENTS ONLY. The input is sanitized HTML, and a `$` can sit inside- // an attribute — `<a href="https://x.example/$a$b">` (web links, #465).- // Run over the whole string, the inline rule paired those two dollars and- // wrote a <math> into the href: a dead link and stray markup (nothing the- // author chose became an attribute, but the link was gone). So the string- // is split on tags, each text run is transformed on its own, and a formula- // can never span or enter a tag.- return html.split(/(<[^>]*>)/).map((part, i) => (i % 2 ? part : resolveMathText(part))).join('')-}--function resolveMathText(text: string): string {- if (text.indexOf('$') < 0) return text- // $$…$$ first (display), then $…$ (inline). The inline form is deliberately- // fussy so ordinary prose survives: no whitespace just inside the delimiters- // and no digit straight after the closer, which is what keeps "it costs $5- // and $10" from parsing as math. A backslash-escaped \$ is a literal dollar.- let out = text.replace(/(^|[^\\])\$\$([^$]+?)\$\$/g, (m, pre: string, src: string) => {- const ml = renderMath(src, true)- return ml ? pre + ml : m- })- out = out.replace(/(^|[^\\$])\$(\S(?:[^$\n]*?\S)?)\$(?!\d)/g, (m, pre: string, src: string) => {- const ml = renderMath(src, false)- return ml ? pre + ml : m- })- return out.replace(/\\\$/g, '$') // the escape has done its job+// Where the formulas are — the four delimiters, text runs only (#465), and+// display formulas across line breaks (#540) — lives in maths/delimiters.ts,+// DOM-free so its rigs drive the code itself.+export function resolveMath(html: string, hint?: (what: string) => string): string {+ return resolveMathHtml(html, renderMath, hint && ((src, display, spaced) => {+ if (spaced) return hint('spaces')+ const tex = decodeEntities(src)+ const m = /^typst:\s*/.exec(tex)+ const why = mathError(m ? tex.slice(m[0].length) : tex, { display, syntax: m ? 'typst' : 'latex' })+ return why ? hint(why) : null+ }))}/**@@ -1184,7 +1174,7 @@ export function renderElement(el: SlideElement, doc: BentoDoc, opts: RenderOptsinner.style.lineHeight = String(el.lineHeight)if (el.letterSpacing) inner.style.letterSpacing = `${el.letterSpacing}px`inner.style.width = '100%'- inner.innerHTML = resolveMath(sanitizeHtml(resolveFields(el.html, opts.fields)))+ inner.innerHTML = resolveMath(sanitizeHtml(resolveFields(el.html, opts.fields)), opts.mathHint)// layout placeholder: prompt while empty (editor), gone while presentingconst isEmpty = !inner.textContent?.trim() && !el.html.includes('<img')if (el.placeholder && isEmpty) {diff --git a/slides/src/styles.css b/slides/src/styles.cssindex 2616a6b5..3b6e5bf7 100644--- a/slides/src/styles.css+++ b/slides/src/styles.css@@ -501,6 +501,16 @@ a.ed-btn { text-decoration: none; } /* the update block's "What's new" link isand still broken on Windows. Read docs/DECISIONS.md, 2026-08-25, beforetouching this; the rig is slides/probe/radical-join.html. */+/* A formula that did not render, on the editor canvas only (render.ts+ mathHint, #540): the author's text stays exactly as typed, a faint dotted+ underline says it was meant as maths, and the title says why. */+.bento-math-miss {+ text-decoration: underline dotted;+ text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);+ text-underline-offset: 0.18em;+ cursor: help;+}+.bento-el-text,.bento-el-code.bento-text-inner {