Add range information to SymbolNode and ConstantNode#3522
Add range information to SymbolNode and ConstantNode#3522serso wants to merge 1 commit intojosdejong:developfrom
Conversation
The parser knows the position of the nodes in the original text and can as well return this information in the node objects. This is useful when implementing the MathJS syntax highlighting in a rich text editor. One drawback of adding "range" property to the node object is that two semantically equal nodes might not be equal when parsed from different strings as their "range" properties might differ. This caused some failures of `assert.deepStrictEqual` in tests.
|
Hey, I've created this PR to get some early feedback from the maintainers/community. What do you think about the change? Is it upstreamable? |
|
Thanks @serso , adding information about the positions of the tokens in the original expression would be useful nice indeed! A few years ago, a PR was made implementing this same idea: #2796. The PR is quite mature already but unfortunately was never finished. I think we can go in two directions from here: either read up on #2796, use it for inspiration and work out a new PR. Or start from #2796, work out the open ends, and rethink it where needed. Would you like to pick this up and if so what approach do you prefer? |
|
Thanks for the tips. I'll check out the old PR. |
|
I have followed up on the old PR, see #3557 |
The parser knows the position of the nodes in
the original text and can as well return this
information in the node objects.
This is useful when implementing the MathJS syntax highlighting in a rich text editor.
One drawback of adding "range" property to the node object is that two semantically equal nodes might not be equal when parsed from different strings as their "range" properties might differ. This caused some
failures of
assert.deepStrictEqualin tests.