Skip to content

Customize supported characters for units #1268

@zcohan

Description

@zcohan

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"

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions