Skip to content

Treat control sequences as a unit when matching a macro template. #1568 #1569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion unpacked/extensions/TeX/newcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,17 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
if (param == null) {return this.GetArgument(name)}
var i = this.i, j = 0, hasBraces = 0;
while (this.i < this.string.length) {
if (this.string.charAt(this.i) === '{') {
var c = this.string.charAt(this.i);
if (c === '{') {
if (this.i === i) {hasBraces = 1}
this.GetArgument(name); j = this.i - i;
} else if (this.MatchParam(param)) {
if (hasBraces) {i++; j -= 2}
return this.string.substr(i,j);
} else if (c === "\\") {
this.i++; j++; hasBraces = 0;
var match = this.string.substr(this.i).match(/[a-z]+|./i);
if (match) {this.i += match[0].length; j = this.i - i}
} else {
this.i++; j++; hasBraces = 0;
}
Expand All @@ -254,6 +259,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
*/
MatchParam: function (param) {
if (this.string.substr(this.i,param.length) !== param) {return 0}
if (param.match(/\\[a-z]+$/i) &&
this.string.charAt(this.i+param.length).match(/[a-z]/i)) {return 0}
this.i += param.length;
return 1;
}
Expand Down