Merge pull request #672 from CarnegieWebLearning/fix.class.latex
Used the \textcolor command as a template for correcting the \class
output. Added tests to latex for \class to prove correctness and for
\textcolor because it was missing.
diff --git a/src/commands/math/commands.js b/src/commands/math/commands.js
index bdccb61..f60f054 100644
--- a/src/commands/math/commands.js
+++ b/src/commands/math/commands.js
@@ -131,11 +131,15 @@
.then(regex(/^[-\w\s\\\xA0-\xFF]*/))
.skip(string('}'))
.then(function(cls) {
+ self.cls = cls || '';
self.htmlTemplate = '<span class="mq-class '+cls+'">&0</span>';
return super_.parser.call(self);
})
;
};
+ _.latex = function() {
+ return '\\class{' + this.cls + '}{' + this.blocks[0].latex() + '}';
+ };
_.isStyleBlock = function() {
return true;
};
diff --git a/test/unit/latex.test.js b/test/unit/latex.test.js
index 5801112..7baa156 100644
--- a/test/unit/latex.test.js
+++ b/test/unit/latex.test.js
@@ -121,6 +121,15 @@
assertParsesLatex('\\text{}', '');
});
+ test('\\textcolor', function() {
+ assertParsesLatex('\\textcolor{blue}{8}', '\\textcolor{blue}{8}');
+ });
+
+ test('\\class', function() {
+ assertParsesLatex('\\class{name}{8}', '\\class{name}{8}');
+ assertParsesLatex('\\class{name}{8-4}', '\\class{name}{8-4}');
+ });
+
test('not real LaTex commands, but valid symbols', function() {
assertParsesLatex('\\parallelogram ');
assertParsesLatex('\\circledot ', '\\odot ');