Here's a minimal example of the problem:
macroList = {"\\mtest": "\\left[ #1 \\right]"}
s = katex.renderToString("\\mtest{x}", {macros: macroList})
should produce the result "[x]" but instead katex throws an error:
Uncaught Error: KaTeX parse error: Expected '\right', got '#' at position 8: \left[ #滩1 \right]
at new ParseError (katex.js:547)
at Parser.expect (katex.js:641)
at Parser.parseImplicitGroup (katex.js:980)
at Parser.parseAtom (katex.js:865)
at Parser.parseExpression (katex.js:719)
at Parser.parseInput (katex.js:683)
at Parser.parse (katex.js:674)
at parseTree (katex.js:8270)
at Object.renderToString (katex.js:53)
at katex_init.js:30
I think this might have something to do with the time at which macro arguments are actually substituted?
Thanks for the report! Thoughts on this, @gagern?
Our latest release, v0.7.1, doesn't contain #605 which introduced this feature. We need to roll a new release soon.
I think we should do a release once https://github.com/Khan/KaTeX/pull/670 lands.
Ah, that makes sense. I didn't find any particular documentation on macros so I think I inferred a lot of information from the github issues. I didn't realize the issue in question hadn't made it into release.
I think we should do a release once #670 lands.
@kevinbarabash release please 馃槃
This issue is resolved now, I think.
I couldn't find any tests that actually verify that this is fixed. I'm going to add a couple of tests and try to split up our tests a little more so we don't end of with all tests in katex-spec.js.