mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-06 19:58:40 +00:00
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
This commit is contained in:
@@ -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|<span style="color:firebrick;">Not supported</span>|[Issue #1003](https://github.com/KaTeX/KaTeX/issues/1003)|
|
||||
|\em|<span style="color:firebrick;">Not supported</span>||
|
||||
@@ -431,7 +431,7 @@ use `\ce` instead|
|
||||
|{gather}|$$\begin{gather}a=b\\e=b+c\end{gather}$$|`\begin{gather}`<br> `a=b \\ `<br> `e=b+c`<br>`\end{gather}`|
|
||||
|{gathered}|$\begin{gathered}a=b\\e=b+c\end{gathered}$|`\begin{gathered}`<br> `a=b \\ `<br> `e=b+c`<br>`\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|<span style="color:firebrick;">Not supported</span>||
|
||||
|\geneuronarrow|<span style="color:firebrick;">Not supported</span>||
|
||||
@@ -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}`|
|
||||
|
@@ -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`
|
||||
|
@@ -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();
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user