Skip to content

Commit d53ad0d

Browse files
committed
Backport fix for template macros with no arguments (mathjax#2901)
1 parent e662bb5 commit d53ad0d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

unpacked/extensions/TeX/newcommand.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,16 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
177177
* Process a macro with a parameter template
178178
*/
179179
MacroWithTemplate: function (name,text,n,params) {
180-
if (n) {
180+
if (params.length) {
181181
var args = []; this.GetNext();
182182
if (params[0] && !this.MatchParam(params[0])) {
183183
TEX.Error(["MismatchUseDef",
184184
"Use of %1 doesn't match its definition",name]);
185185
}
186-
for (var i = 0; i < n; i++) {args.push(this.GetParameter(name,params[i+1]))}
187-
text = this.SubstituteArgs(args,text);
186+
if (n) {
187+
for (var i = 0; i < n; i++) {args.push(this.GetParameter(name,params[i+1]))}
188+
text = this.SubstituteArgs(args,text);
189+
}
188190
}
189191
this.string = this.AddArgs(text,this.string.slice(this.i));
190192
this.i = 0;

0 commit comments

Comments
 (0)