Customize supported characters for units
Following the instructions in the documentation on overriding the 'math.expression.parse.isAlpha' function, I have successfully customised supported characters for variables.
Can I do the same for units? The issue I'm running into is syntax errors when defining aliases for certain currencies with non-alpha symbols (i.e '£' for GBP & '€' for EUR).
Here's my code:
math.createUnit('USD')
math.createUnit('EUR', {definition: '1.18 USD', aliases: ['€']})
math.eval('10 USD in €')
I get "SyntaxError: Unexpected "€" in "€" at index 0"
Good point!
Right now Unit has its own parseUnit function which only allows a-zA-Z0-9. I think it should use the the math.expression.parse.isAlpha instead, to make the behavior consistent.
Anyone interested in implementing this change? I don't think it's very complicated.
Any updates on this? Thanks!
No one picked it up yet, help would be welcome