Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize supported characters for units #1268

Closed
zcohan opened this issue Sep 30, 2018 · 3 comments
Closed

Customize supported characters for units #1268

zcohan opened this issue Sep 30, 2018 · 3 comments

Comments

@zcohan
Copy link

zcohan commented Sep 30, 2018

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"

@josdejong
Copy link
Owner

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.

@larissa-n
Copy link

Any updates on this? Thanks!

@josdejong
Copy link
Owner

No one picked it up yet, help would be welcome

Repository owner locked and limited conversation to collaborators Sep 2, 2022
@josdejong josdejong converted this issue into discussion #2760 Sep 2, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

3 participants