From 92ac286a3a149c66423bbd4cdeae4fd179cd48c5 Mon Sep 17 00:00:00 2001 From: Erik Demaine Date: Tue, 11 Apr 2023 11:29:06 -0400 Subject: [PATCH] docs: Fix \bar documentation by avoiding global redefinition (#3804) * `\bar` examples weren't rendering correctly because of `\gdef\bar` example when illustrating `\gdef` and `\xdef`. * Improve `\bar` name to `\sqr` when defining squaring (not necessary for fix, but improved naming). * Fix `\def` scoping test that originally seemed related. Fixes #3803 --- docs/support_table.md | 8 ++++---- docs/supported.md | 2 +- test/katex-spec.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/support_table.md b/docs/support_table.md index 6e3c2bad..8769a25f 100644 --- a/docs/support_table.md +++ b/docs/support_table.md @@ -22,7 +22,7 @@ $\gdef\VERT{|}$ |:---------------|:------------|:-----------------| |\!|$n!$|`n!`| |\\\!|$a\!b$|`a\!b`| -|#|$\def\bar#1{#1^2} \bar{y}$|`\def\bar#1{#1^2} \bar{y}`| +|#|$\def\sqr#1{#1^2} \sqr{y}$|`\def\sqr#1{#1^2} \sqr{y}`| |\\#|$\#$|| |%||`%this is a comment`| |\\%|$\%$|| @@ -365,7 +365,7 @@ use `\ce` instead| |Symbol/Function | Rendered | Source or Comment| |:---------------|:------------|:-----------------| -|\edef|$\def\foo{a}\edef\bar{\foo}\def\foo{}\bar$|`\def\foo{a}\edef\bar{\foo}\def\foo{}\bar`| +|\edef|$\def\foo{a}\edef\fcopy{\foo}\def\foo{}\fcopy$|`\def\foo{a}\edef\fcopy{\foo}\def\foo{}\fcopy`| |\ell|$\ell$|| |\else|Not supported|[Issue #1003](https://github.com/KaTeX/KaTeX/issues/1003)| |\em|Not supported|| @@ -431,7 +431,7 @@ use `\ce` instead| |{gather}|$$\begin{gather}a=b\\e=b+c\end{gather}$$|`\begin{gather}`
   `a=b \\ `
   `e=b+c`
`\end{gather}`| |{gathered}|$\begin{gathered}a=b\\e=b+c\end{gathered}$|`\begin{gathered}`
   `a=b \\ `
   `e=b+c`
`\end{gathered}`| |\gcd|$\gcd$|| -|\gdef|$\gdef\bar#1{#1^2} \bar{y} + \bar{y}$|`\gdef\bar#1{#1^2} \bar{y} + \bar{y}`| +|\gdef|$\gdef\sqr#1{#1^2} \sqr{y} + \sqr{y}$|`\gdef\sqr#1{#1^2} \sqr{y} + \sqr{y}`| |\ge|$\ge$|| |\geneuro|Not supported|| |\geneuronarrow|Not supported|| @@ -1242,7 +1242,7 @@ use `\ce` instead| |Symbol/Function | Rendered | Source or Comment| |:---------------|:------------|:-----------------| |\xcancel|$\xcancel{ABC}$|`\xcancel{ABC}`| -|\xdef|$\def\foo{a}\xdef\bar{\foo}\def\foo{}\bar$|`\def\foo{a}\xdef\bar{\foo}\def\foo{}\bar`| +|\xdef|$\def\foo{a}\xdef\fcopy{\foo}\def\foo{}\fcopy$|`\def\foo{a}\xdef\fcopy{\foo}\def\foo{}\fcopy`| |\Xi|$\Xi$|| |\xi|$\xi$|| |\xhookleftarrow|$\xhookleftarrow{abc}$|`\xhookleftarrow{abc}`| diff --git a/docs/supported.md b/docs/supported.md index 508ce413..73017961 100644 --- a/docs/supported.md +++ b/docs/supported.md @@ -332,7 +332,7 @@ Direct Input: $∀ ∴ ∁ ∵ ∃ ∣ ∈ ∉ ∋ ⊂ ⊃ ∧ ∨ ↦ → ← ||| |:-------------------------------------|:------ |$\def\foo{x^2} \foo + \foo$ | `\def\foo{x^2} \foo + \foo` -|$\gdef\bar#1{#1^2} \bar{y} + \bar{y}$ | `\gdef\bar#1{#1^2} \bar{y} + \bar{y}` +|$\gdef\foo#1{#1^2} \foo{y} + \foo{y}$ | `\gdef\foo#1{#1^2} \foo{y} + \foo{y}` | | `\edef\macroname#1#2…{definition to be expanded}` | | `\xdef\macroname#1#2…{definition to be expanded}` | | `\let\foo=\bar` diff --git a/test/katex-spec.js b/test/katex-spec.js index a2b088b3..b0ebbeba 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -3471,7 +3471,7 @@ describe("A macro expander", function() { it("\\def changes settings.macros with globalGroup", () => { const macros = {}; - expect`\gdef\foo{1}`.toParse(new Settings({macros, globalGroup: true})); + expect`\def\foo{1}`.toParse(new Settings({macros, globalGroup: true})); expect(macros["\\foo"]).toBeTruthy(); });