Skip to content

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

Open

Description

@gbala2412

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

Activity

  1. pkra commented on Jun 27, 2019

    @pkra
    Contributor

    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.

  2. dpvc commented on Jun 27, 2019

    @dpvc
    Member

    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.

  3. gbala2412 commented on Jun 27, 2019

    @gbala2412
    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

  4. dpvc commented on Jun 27, 2019

    @dpvc
    Member

    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.

  5. dpvc commented on Jun 27, 2019

    @dpvc
    Member

    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.

  6. gbala2412 commented on Jun 28, 2019

    @gbala2412
    Author

    Thank you!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions