Open RajaTheKing826 opened 1 year ago
Hm, I'm not sure if you mean invalid operators as in the mathematical operator is not allowed ("multiplication is not allowed") or the specific character used to express the operation is not allowed ("the asterisk operator (U+2217) is not allowed").
If it is the former, I am not sure if and how that feature would be supported. It could possibly be made using some kind of filter on the AST. You could handle it yourself, though, by manually using parse
from kgram/equation-parser , recursively going through the AST and throwing an error if an invalid type is present. The types are well documented and also has typescript support in the EquationNode
type, so it should not be that difficult.
If it is the latter, I think it makes sense to add the ability to customized which characters map to which operator in kgram/equation-parser , essentially an override for the operatorMap
, and expose the setting here. Unfortunately, I don't have time to do it myself at the moment, and looking at it, the typing may be non-trivial. Feel free to open an MR, though. A workaround could be to use a regex to check for invalid characters before parsing as an equation.
@kgram
We want allowed operators support in react-equation. Because some of the operators that you are supporting are not valid in our case.
So kindly add allowed operators support.