mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-07 04:08:43 +00:00
fix: Prevent global group from adversely affecting color. (#2703)
Co-authored-by: ylemkimon <y@ylem.kim>
This commit is contained in:
@@ -18,10 +18,16 @@ const parseTree = function(toParse: string, settings: Settings): AnyParseNode[]
|
||||
throw new TypeError('KaTeX can only parse string typed expression');
|
||||
}
|
||||
const parser = new Parser(toParse, settings);
|
||||
|
||||
// Blank out any \df@tag to avoid spurious "Duplicate \tag" errors
|
||||
delete parser.gullet.macros.current["\\df@tag"];
|
||||
|
||||
let tree = parser.parse();
|
||||
|
||||
// Prevent a color definition from persisting between calls to katex.render().
|
||||
delete parser.gullet.macros.current["\\current@color"];
|
||||
delete parser.gullet.macros.current["\\color"];
|
||||
|
||||
// If the input used \tag, it will set the \df@tag macro to the tag.
|
||||
// In this case, we separately parse the tag and wrap the tree.
|
||||
if (parser.gullet.macros.get("\\df@tag")) {
|
||||
|
@@ -869,6 +869,7 @@ describe("A color parser", function() {
|
||||
const macros = {};
|
||||
expect(oldColorExpression).toParseLike(r`\textcolor{#fA6}{x}y`, {
|
||||
colorIsTextColor: true,
|
||||
globalGroup: true,
|
||||
macros: macros,
|
||||
});
|
||||
expect(macros).toEqual({});
|
||||
|
Reference in New Issue
Block a user