Skip to content

Fix problems with defining \ (control-space). #1563 and #1564 #1565

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 1 commit into from
Jul 23, 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
17 changes: 10 additions & 7 deletions unpacked/extensions/TeX/newcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
* Implement \newcommand{\name}[n][default]{...}
*/
NewCommand: function (name) {
var cs = this.trimSpaces(this.GetArgument(name)),
var CS = this.GetArgument(name), cs = this.trimSpaces(CS),
n = this.GetBrackets(name),
opt = this.GetBrackets(name),
def = this.GetArgument(name);
if (cs.charAt(0) === "\\") {cs = cs.substr(1)}
if (cs === "" && CS.substr(CS.length-1,1) === " ") {cs += " "}
if (!cs.match(/^(.|[a-z]+)$/i)) {
TEX.Error(["IllegalControlSequenceName",
"Illegal control sequence name for %1",name]);
Expand Down Expand Up @@ -120,10 +121,11 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
name = this.GetCSname(name);
macro = this.csFindMacro(name);
if (!macro) {
if (TEXDEF.mathchar0mi[name]) {macro = ["csMathchar0mi",TEXDEF.mathchar0mi[name]]} else
if (TEXDEF.mathchar0mo[name]) {macro = ["csMathchar0mo",TEXDEF.mathchar0mo[name]]} else
if (TEXDEF.mathchar7[name]) {macro = ["csMathchar7",TEXDEF.mathchar7[name]]} else
if (TEXDEF.delimiter["\\"+name] != null) {macro = ["csDelimiter",TEXDEF.delimiter["\\"+name]]}
if (TEXDEF.mathchar0mi[name]) {macro = ["csMathchar0mi",TEXDEF.mathchar0mi[name]]} else
if (TEXDEF.mathchar0mo[name]) {macro = ["csMathchar0mo",TEXDEF.mathchar0mo[name]]} else
if (TEXDEF.mathchar7[name]) {macro = ["csMathchar7",TEXDEF.mathchar7[name]]} else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all just whitespace change. See my comments on tabs earlier...

Copy link
Member Author

@dpvc dpvc Jul 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there was a space added before the else so the they lined up with the new one in the line below. This wasn't due to tabbing, but to actual space changes.

if (TEXDEF.delimiter["\\"+name] != null) {macro = ["csDelimiter",TEXDEF.delimiter["\\"+name]]} else
return;
}
} else {macro = ["Macro",c]; this.i++}
this.setDef(cs,macro);
Expand All @@ -145,8 +147,9 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
TEX.Error(["MissingCS",
"%1 must be followed by a control sequence", cmd])
}
var cs = this.trimSpaces(this.GetArgument(cmd));
return cs.substr(1);
var cs = this.GetArgument(cmd), CS = this.trimSpaces(cs);
if (CS == "\\" && cs.substr(cs.length-1,1) === " ") {CS += " "}
return CS.substr(1);
},

/*
Expand Down