cortex-js / compute-engine

An engine for symbolic manipulation and numeric evaluation of math formulas expressed with MathJSON
https://cortexjs.io
MIT License
356 stars 42 forks source link

Compute engine can't parse the latex "\log_{frac{122}{2}} (b^{2c})" #142

Closed renanlr closed 6 months ago

renanlr commented 6 months ago

Description

Compute engine can't parse the latex \log_{\frac{122}{2}} (b^{2c})

Steps to Reproduce

  1. Run the following code:
- const expr = ce.parse(String.raw`\log_{frac{122}{2}}(b^{2c})`);
+ const expr = ce.parse(String.raw`\log_{\frac{122}{2}}(b^{2c})`);
console.log("Errors:", expr.errors);

Actual Behavior

- Errors: [Error("invalid-identifier", "frac\{122\}\{2\}")]
+ Errors: [Error("invalid-identifier", "\frac\{122\}\{2\}")]

Expected Behavior

The latex should be parsed correctly

Errors: []

Environment

MathLive version 0.23.1

Operating System macOS 13.4.1

Browser It's failing the same way in Safari, Chrome and Firefox

arnog commented 6 months ago

There appears to be a “\” missing in front of the “frac” command.

renanlr commented 6 months ago

Sorry, my mistake, But even when I add the "\" the problem persists.

arnog commented 6 months ago

The Log function expects either a number or an identifier in the subscript. Did you actually intend to have an expression there?