From 43675748985bdf1a02e977d4f6cfdeadb3b96c4e Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sun, 10 Dec 2023 07:53:47 -0500 Subject: [PATCH] Fix problem with let using attributes of {} when they should be null --- ts/input/tex/newcommand/NewcommandMethods.ts | 10 ++--- ts/input/tex/newcommand/NewcommandUtil.ts | 42 -------------------- 2 files changed, 3 insertions(+), 49 deletions(-) diff --git a/ts/input/tex/newcommand/NewcommandMethods.ts b/ts/input/tex/newcommand/NewcommandMethods.ts index abf3670e4..b9bb10e6d 100644 --- a/ts/input/tex/newcommand/NewcommandMethods.ts +++ b/ts/input/tex/newcommand/NewcommandMethods.ts @@ -133,13 +133,9 @@ NewcommandMethods.Let = function(parser: TexParser, name: string) { return; } macro = (map as sm.CharacterMap).lookup(name) as Token; - const newArgs = NewcommandUtil.disassembleToken(cs, macro); - const method = (p: TexParser, _cs: string, ...rest: any[]) => { - // @test Let Relet, Let Let, Let Circular Macro - const symb = NewcommandUtil.assembleToken(rest); - return map.parser(p, symb); - }; - NewcommandUtil.addMacro(parser, cs, method, newArgs); + // @test Let Relet, Let Let, Let Circular Macro + const method = (p: TexParser) => map.parser(p, macro); + NewcommandUtil.addMacro(parser, cs, method, [cs, macro.char]); return; } // @test Let Brace Equal, Let Caret diff --git a/ts/input/tex/newcommand/NewcommandUtil.ts b/ts/input/tex/newcommand/NewcommandUtil.ts index 299e122c8..55dab52a7 100644 --- a/ts/input/tex/newcommand/NewcommandUtil.ts +++ b/ts/input/tex/newcommand/NewcommandUtil.ts @@ -33,48 +33,6 @@ import * as sm from '../TokenMap.js'; namespace NewcommandUtil { - /** - * Transforms the attributes of a token into the arguments of a macro. E.g., - * Token('ell', 'l', {mathvariant: "italic"}) is turned into Macro arguments: - * ['ell', 'l', 'mathvariant', 'italic']. - * - * @param {string} name The command name for the token. - * @param {Token} token The token associated with name. - * @return {Args[]} Arguments for a macro. - */ - export function disassembleToken(name: string, token: Token): Args[] { - let newArgs = [name, token.char] as Args[]; - // @test Let Relet, Let Let, Let Circular Macro - if (token.attributes) { - // @test Let Relet - for (let key in token.attributes) { - newArgs.push(key); - newArgs.push(token.attributes[key] as Args); - } - } - return newArgs; - } - - - /** - * Assembles a token from a list of macro arguments. This is the inverse - * method of the one above. - * - * @param {Args[]} args The arguments of the macro. - * @return {Token} The Token generated from the arguments.. - */ - export function assembleToken(args: Args[]): Token { - // @test Let Relet, Let Let, Let Circular Macro - let name = args[0] as string; - let char = args[1] as string; - let attrs: Attributes = {}; - for (let i = 2; i < args.length; i = i + 2) { - // @test Let Relet - attrs[args[i] as string] = args[i + 1]; - } - return new Token(name, char, attrs); - } - /** * Get the next CS name or give an error. * @param {TexParser} parser The calling parser.