Add math engine based on MathJax-node that outputs to MathML #240
Add math engine based on MathJax-node that outputs to MathML #240tmthrgd wants to merge 6 commits intogettalong:masterfrom tmthrgd:master
Conversation
There was a problem hiding this comment.
Better not use a pipe when a simple result = #{cmd << el.value}.strip would suffice since some systems might not support pipes.
There was a problem hiding this comment.
It's not quite that easy. The raw value of the TeX is passed in the command line. If you use #{cmd << el.value}, or similar, it becomes trivial to craft input that will execute arbitrary programs. Using IO.popen with an array as the first argument causes ruby bypasses the shell: "If cmd is an Array of String, then it will be used as the subprocess’s argv bypassing a shell.". Doing it this way prevents those exploits.
There was a problem hiding this comment.
Okay, thanks for the explanation. I have been using the systemu library in such cases which should work on any system. Just that I know: Would IO.popen work on Windows?
There was a problem hiding this comment.
It certainly should. It appears that systemu itself calls IO.popen to execute commands on all systems, with the exception of JRuby which is using java.lang.Runtime.runtime.exec.
Easy fixed.
Easy fixed.
|
Thanks for this math engine! As for the name: I haven't done anything with node.js yet but I gather that node.js does have a Markdown library, so the target audience would be Ruby developers. Would it be better to name this engine something like 'MathJax-MathML'? As for testing: Do you know what to put into the |
|
I named it to be consistent with the underlying library but what your saying does make sense. I'll look into the |
|
Thanks! |
|
All the errors attributed to 'Problem using tidy' look something like this: When tidy is removed the tests pass on my machine but fail when tidy is installed. Edit: I have solved all of the tidy issues; I hadn't noticed the exclusions. |
|
Unfortunately |
|
You can just remove support for Ruby 1.8.7 from the engine since the engine isn't bound by backwards compatibility yet. Please also state this in its documentation! |
|
Hurrah! All tests are passing. It's your call on the name though. |
|
Thanks for all your work! Regarding the name: I will let the information sink in some time and then decide. This will be in the next release. |
|
👍 You're welcome. |
|
@tmthrgd I'm just integrating your code for the next release. After some problems with nodejs/npm that I needed to fix the tests work fine. However, they take ages to run. Is node.js that slow? Or has this to do with MathJax-node? Anyway, the additional tests take a whooping 20 seconds to execute whereas the whole test suite needed 35 seconds before... That's not optimal. Do you know of a way to speed up the MathJax-node tests? |
|
I have merged your commits into one and pushed to master, ie. your changes are now live. Regarding the slow tests: I will modify the test suite so that slow tests are not executed depending on an environment variable. |
|
@tmthrgd New commits fail in Travis due to an error with When I test locally everything works fine - do you know why this happens? |
|
@gettalong I was able to recreate the error locally after running |
This adds a new math engine based on MathJax-node. MathJax-node runs the MathJax conversion in node.js. mathjaxnode.rb converts the TeX code to MathML in a node.js subprocess using the MathJax-node bundled tex2mml command.