-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add support for cdot and times LaTeX commands #6
Conversation
Why are What's the use case here? |
Apologies, I read through the code to get a better understanding and made an incorrect assumption I should use the localFunctions pattern to add support for these instead of the lexer (since they're infix ops as you mention). I made the changes you mention, updated my tests and all are passing. The use case is to support MathQuill syntax, which here is an example on their doc website. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I left some nitpicks but seems OK to merge after they're resolved.
@@ -9,6 +9,7 @@ | |||
"private": false, | |||
"scripts": { | |||
"build": "babel -d dist src && webpack dist/minifier.js -o dist/evaluatex.min.js", | |||
"postinstall": "npm run build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the postinstall? The NPM package ships with Babel and minified ES sources. We don't want end users of the library to build it on every install.
// `b` isn't bound | ||
test("{a}\\cdot{b}", undefined, { a: 2 }, {}, { latex: true }); | ||
} catch(err) { | ||
assert.equal(true, err instanceof Error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion should also check that the error message is correct and helpful, otherwise it passes on any error.
Chai also has an instanceOf assertion that would be more semantic here.
// `a` is a string | ||
test("{a}\\cdot{b}", 4, { a: '2', b: 2 }, {}, { latex: true }); | ||
} catch(err) { | ||
assert.equal(true, err instanceof Error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above
Any chance you merge this? |
Merged and published version |
Fixes the
times
problem mentioned in #1, but could probably as you mention add a thorough test suite for LaTeX commands in the future. For my use case I at least need support forcdot
andtimes
. All other iterations I've tried for my needs work otherwise though.