fred-wang / TeXZilla

LALR Javascript LaTeX-to-MathML converter compatible with Unicode
http://fred-wang.github.io/TeXZilla/
130 stars 21 forks source link

Use `phantom.injectJs` instead of `require` #3

Closed rgaiacs closed 10 years ago

rgaiacs commented 10 years ago

The file commonJS.js exists because of the line

var parser = require("./TeXZilla").parser;

in unit-tests.js.

What about replace this line with

phantom.injectJs("./TeXZilla.js");

and remove the file commonJS.js?

fred-wang commented 10 years ago

The file commonJS.js exists to make TeXZilla usable in any program that uses Common JS interface, not specifically for the testing. It would be possible to generate separate versions, one for the Web only and another with the common JS interface. However at the moment the overhead of the common JS interface is small compared to the rest of the script...

Also I'd like to make the unit tests use a standard common JS interface so that you can run it with your favorite common JS program like NodeJS (Blink), phantomJS (WebKit) or slimerJS (Gecko). At the moment, there is one non-standard slimerJS command for exit that I'd like to drop when common JS is more standardized. I don't want to add specific phantomJS commands.

rgaiacs commented 10 years ago

Thanks for the explanation.

fred-wang commented 10 years ago

The Makefile now generates proceeds that way:

In particular, commonJS.js can now be modified without having to rebuild the whole parser. And TeXZilla-min.js no longer has the commonJS API (which is a bit bigger now).