Skip to content

Currency symbols ($, € etc.) as a unit alias? #2673

Answered by larissa-n
xxczaki asked this question in Q&A
Discussion options

You must be logged in to vote

You don't have to override math.parse.isAlpha since it it's not used in conjunction with math.Unit as it stands currently. But you're right, you can just customize math.Unit.isValidAlpha. So something like this would do:

const isUnitAlphaOriginal = math.Unit.isValidAlpha;
math.Unit.isValidAlpha = function (c, cPrev, cNext) {
   return isUnitAlphaOriginal(c, cPrev, cNext) || ['$', '€'].includes(c)
};

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by josdejong
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants
Converted from issue

This discussion was converted from issue #1880 on August 17, 2022 12:41.