Skip to content

Commit 4ea6e97

Browse files
authored
Merge pull request #1569 from dpvc/issue1568
Treat control sequences as a unit when matching a macro template. #1568
2 parents 1179e74 + c5b61d4 commit 4ea6e97

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

unpacked/extensions/TeX/newcommand.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,17 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
234234
if (param == null) {return this.GetArgument(name)}
235235
var i = this.i, j = 0, hasBraces = 0;
236236
while (this.i < this.string.length) {
237-
if (this.string.charAt(this.i) === '{') {
237+
var c = this.string.charAt(this.i);
238+
if (c === '{') {
238239
if (this.i === i) {hasBraces = 1}
239240
this.GetArgument(name); j = this.i - i;
240241
} else if (this.MatchParam(param)) {
241242
if (hasBraces) {i++; j -= 2}
242243
return this.string.substr(i,j);
244+
} else if (c === "\\") {
245+
this.i++; j++; hasBraces = 0;
246+
var match = this.string.substr(this.i).match(/[a-z]+|./i);
247+
if (match) {this.i += match[0].length; j = this.i - i}
243248
} else {
244249
this.i++; j++; hasBraces = 0;
245250
}
@@ -254,6 +259,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
254259
*/
255260
MatchParam: function (param) {
256261
if (this.string.substr(this.i,param.length) !== param) {return 0}
262+
if (param.match(/\\[a-z]+$/i) &&
263+
this.string.charAt(this.i+param.length).match(/[a-z]/i)) {return 0}
257264
this.i += param.length;
258265
return 1;
259266
}

0 commit comments

Comments
 (0)