Skip to content
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

in command line not able to escape single quote character in mathml #444

Open
gbala2412 opened this issue Jun 27, 2019 · 6 comments
Open

Comments

@gbala2412
Copy link

gbala2412 commented Jun 27, 2019

Error: bash: syntax error near unexpected token `<'

Not able to escape single quote character
node /usr/local/lib/node_modules/mathjax-node-cli/bin/mml2svg '<math><mi>μ</mi><msup><mrow><mo>'</mo></mrow><mrow><mn>2</mn></mrow></msup></math>' > eqn.svg

@pkra
Copy link
Contributor

pkra commented Jun 27, 2019

CLI issues belong in its repository https://github.com/mathjax/mathjax-node-cli

But I suspect it's just the apostrophe in the mml expression that is closing the argument.

@dpvc
Copy link
Member

dpvc commented Jun 27, 2019

Peter is correct, the problem is the internal ' which closes the initial ' being used as the quotation mark, so the rest of the MathML is being interpreted by bash as part of the command. Try

bin/mml2svg "<math><mi>μ</mi><msup><mrow><mo>'</mo></mrow><mrow><mn>2</mn></mrow></msup></math>" > eqn.svg

instead.

@gbala2412
Copy link
Author

Sorry I am already tried the double quotes also which I forgot to mention. That also throws error if the mathml contains attributes.

node /usr/local/lib/node_modules/mathjax-node-cli/bin/mml2svg "<math><mi mathvariant="normal">μ</mi><msup><mrow><mo>'</mo></mrow><mrow><mn>2</mn></mrow></msup></math>" > eqn.svg MathML - Error parsing MathML: Unquoted attribute value Column: 66 Char: n

@dpvc
Copy link
Member

dpvc commented Jun 27, 2019

Yes, these are the issues you face when trying to pass content containing quotation marks to command-line programs. One solution would be to use single quotes for the attribute values

bin/mml2svg "<math><mi mathvariant='normal'>μ</mi><msup><mrow><mo>'</mo></mrow><mrow><mn>2</mn></mrow></msup></math>" > eqn.svg

as this is still valid MathML. Alternatively, you can replace the internal ' with &prime;:

bin/mml2svg '<math><mi mathvariant="normal">μ</mi><msup><mrow><mo>&prime;</mo></mrow><mrow><mn>2</mn></mrow></msup></math>' > eqn.svg

But you will have to modify the original string in some way if it contains both " and ' internally. Either that, or you will need to modify mml2svg in order to take its input from STDIN instead of as a parameter, for example, so that you can pass the MathML string to it directly as input rather than as a command-line parameter, which avoids the problem with command-line special characters.

@dpvc
Copy link
Member

dpvc commented Jun 27, 2019

In any case, none of these are problems with mathjax-node itself, but with your interaction with your command shell, so are really outside the scope of this issue tracker.

@gbala2412
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants