mathjax / mathjax-node-cli

CLI tools for mathjax-node
Apache License 2.0
33 stars 13 forks source link

Error to parse when the latex formula starts with - #9

Closed isfegu closed 5 years ago

isfegu commented 6 years ago

Hello, Using mathjax-node-cli@1.0.0, I'm trying to transform the following LaTeX formula: -519^\circ + 360^\circ = -159^\circ to svg using tex2svg.

tex2svg --inline --extensions='TeX/cancel,TeX/AMSmath,TeX/AMSsymbols' '-519^\circ + 360^\circ = -159^\circ'

Shell returns the following message (translated from spanish):

Non-optional arguments are needed: Number received 0, need at least 1

The same formula without the first - works.

Using mathjax-node-cli@1.0.1 (if my issue has been resolved) then any formula (well, any tex2svg execution) throws the following error:

/usr/local/lib/node_modules/mathjax-node-cli/node_modules/jsdom/lib/api.js:10 const { URL } = require("whatwg-url"); SyntaxError: Unexpected token {

Could someone give me some tip about this? Thanks in advance, Israel

dpvc commented 6 years ago

Note that an argument that begins with a minus sign (even if it is in quotation marks) looks like an option to most unix programs, so tex2svg '-1' looks like you are using the -1 option of the tex2svg program (if there were one).

This is true of most unix programs, so the standard way to indicate the end of the options and the beginning of the arguments is to use -- between them, as in tex2svg -- '-1'. This will make the -1 be the argument to tex2svg rather than an option. This is standard unix command-line notation.

The library used to read the command-line options and arguments was upgraded in 1.0.1, and so it will read -1 as an argument, not an option, so updating to 1.0.1 is also a way to work around this. The message you are getting seems to be complaining about the ES6 notation used in the jsdom library that is a dependency of mathjax-node. That suggests that you may need to update your version of node.js to at least node version 6 (if I recall correctly, that was the version that implements ES6).

isfegu commented 6 years ago

@dpvc thanks a lot for your early response.

I used -- before the LaTeX formula and now all works fine.

Regarding 1.0.1 version and the nodejs upgrading. I'll do as soon as possible.

Thanks for your time and work.