Closed Carreau closed 2 years ago
A time ago I saw a similar question on the tree-sitter repo https://github.com/tree-sitter/tree-sitter/issues/497. And as far as I know, no other grammars have whitespace nodes.
Ok, thanks for the pointer, so it seem like it's a no from what I can tell.
I wrote my own wrapper/proxy around the node class that is a drop-in replacement but insert whitespace nodes when iterating on children. Feel free to close.
This is more of a question about design and usability of API than a bug per se I I belive I can completely get the information I need from the current API, and it may be a dumb question as I'm not that familiar with tree sitter.
Would be it easy/possible to get whitespace nodes when parsing it would be easier to ignore them than to reconstruct them.
The reason is when parsing something like
"Element-wise maximum of two *arrays*"
and see that one get 6Node kind="text"
, to"".join(...)
to get the text back. Though there is no spaces betweenElement
,-
andwise
. Of course I can just iterate and check ifstart_point
andend_point
, but I though maybe it was easy to do in tree-sitter-rst, in particular as I don't believe the end user is suppose to createNode
objects.