Skip to content

preserveLatex doesn't preserve LaTeX in 3x+y #29

@bengolds

Description

@bengolds

The preserveLaTeX option works most of the time, but it misses preserving the LaTeX at a level sometimes. For example, in the expression 3x+y, you get:

{
  latex: '3x+y',
  fn: [
    'Add',
    [ 'Multiply', { num: '3', latex: '3' }, { latex: 'x', sym: 'x' } ], // This is short form! We'd expect long form with latex.
    { latex: 'y', sym: 'y' }
  ]
}

// instead of

{
  latex: '3x+y',
  fn: [
    'Add',
    {
      latex: '3x'
      fn: [ 'Multiply', { num: '3', latex: '3' }, { latex: 'x', sym: 'x' } ]},
    }
    { latex: 'y', sym: 'y' }
  ]
}

Quick Repro:

node - << 'EOF'
    const util = require('util')
    const CE = require("@cortex-js/compute-engine")
    const myParse = new CE.LatexSyntax({preserveLatex: true})
    console.log(util.inspect(myParse.parse('3x+y'), {depth: null}))
EOF

This prints out:

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions