Modify Symbol to fix text() output for functions
Keeps track of which SymbolCommands are functions (sin, log, etc) and
makes sure that they produce proper .text() output. Closes 537.
diff --git a/src/commands/math/basicSymbols.js b/src/commands/math/basicSymbols.js
index 7f44356..4fc0671 100644
--- a/src/commands/math/basicSymbols.js
+++ b/src/commands/math/basicSymbols.js
@@ -24,13 +24,22 @@
};
_.text = function() {
var text = this.ctrlSeq;
- if (this[L] && !(this[L] instanceof Variable)
- && !(this[L] instanceof BinaryOperator)
- && this[L].ctrlSeq !== "\\ ")
- text = '*' + text;
- if (this[R] && !(this[R] instanceof BinaryOperator)
- && !(this[R] instanceof SupSub))
- text += '*';
+ if (this.isPartOfOperator) {
+ if (text[0] == '\\') {
+ text = text.slice(1, text.length);
+ }
+ else if (text[text.length-1] == ' ') {
+ text = text.slice (0, text.length-1);
+ }
+ } else {
+ if (this[L] && !(this[L] instanceof Variable)
+ && !(this[L] instanceof BinaryOperator)
+ && this[L].ctrlSeq !== '\\ ')
+ text = '*' + text;
+ if (this[R] && !(this[R] instanceof BinaryOperator)
+ && !(this[R] instanceof SupSub))
+ text += '*';
+ }
return text;
};
});
@@ -83,6 +92,7 @@
};
_.italicize = function(bool) {
this.isItalic = bool;
+ this.isPartOfOperator = !bool;
this.jQ.toggleClass('mq-operator-name', !bool);
return this;
};