compute-engine
compute-engine copied to clipboard
Parsing variable names (chars without spaces between) results in a `Multiply` element with a list
parse("Pts_{total} =") // ["Multiply","P","t",["Subscript","s",["Multiply","t","o","t","a","l"]]]
This is how it looks like, it's basically a variable name for total points.

I understand the reason to wrap it in Multiply, yet I'm not sure how to deal with it... Wrapping it in \text{} changes formatting, keeping it like it is now obscures the AST... If you don't have a suggestion / solution, feel free to close this issue, it seems to be a somewhat fundamental ambiguity in the semantic interpretation of LaTEX.
If you have a finite set, you can define entries in the dictionary:
const customLatex = new LatexSyntax({
dictionary:
[...LatexSyntax.getDictionary(),
{
name: 'Pts', // MathJSON symbol
trigger: { symbol: ['P', 't', 's'] } // symbol is an array of Latex tokens
}
]
});
If you have an arbitrary set, you can define a dictionary entry with a custom parse function:
const customLatex = new LatexSyntax({
dictionary:
[...LatexSyntax.getDictionary(),
{
parse: (lhs: Expression, scanner: Scanner, minPrec: number) : string => {
// parsing code goes here...
}
}
]
});
Interesting, I might try the custom parse function option and see if that helps! Thanks a lot for the quick response!